Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

can we add two numbers without using arthematic operators?
if possible how?

Answer Posted / mohan

public static int addIterative(int a, int b){
while (b != 0){
int carry = (a & b) ; //CARRY is AND of two bits

a = a ^b; //SUM of two bits is A XOR B

b = carry << 1; //shifts carry to 1 bit to calculate sum
}
return a;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is private static class in java?

1025


What is annotation in java?

1056


What is an empirical question?

968


Difference between string, stringbuffer and stringbuilder?

1034


What is java thread dump, how can we get java thread dump of a program?

1009


What is classes in java?

947


What is a dot notation?

1039


What are java packages?

1042


What is the difference between final, finally and finalize()?

1160


Enlist few advantages of inheritance?

1076


Difference between throw and throws?

1109


explain different ways of using thread? : Java thread

1017


what is the messsage u r going to get from an objectoriented programing?

2110


What is string in java? String is a data type?

1025


What will happen if non-synchronized method calls a static synchronized method and what kind of lock it acquires?

1115