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

Explain, java is compatible with all servers but not all browsers?

1107


What is meant by final class?

1183


How to perform linear search in java?

993


What do u mean by variable?

1114


What is the size of a string in java?

1073


How do you empty a list in java?

1018


how to open and edit XML file in Weblogic???

2012


What does 3 dots mean in java?

1034


Does printwriter create a file?

1012


What is meant by bytecode?

1078


Is logger a singleton?

1015


Why are constructors used?

1072


What is null in java?

1025


Explain about fail safe iterators in java?

1081


What are the disadvantages of object oriented programming?

1337