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 the difference between heap memory and stack memory?

1019


Why do we need hashset in java?

998


Can an arraylist be empty?

1016


What is a dynamic array in java?

1114


What is 32 bit float?

936


Can we override private method?

1046


What is vector capacity in java?

1039


List implementations of list interface?

995


What are java packages?

983


Explain throw keyword in java?

997


Explain about data types?

1015


Can we increase size of array?

982


Difference between == and .equals() ?

956


Difference between a class and an object?

978


What is integer valueof?

1057