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
Explain, java is compatible with all servers but not all browsers?
What is meant by final class?
How to perform linear search in java?
What do u mean by variable?
What is the size of a string in java?
How do you empty a list in java?
how to open and edit XML file in Weblogic???
What does 3 dots mean in java?
Does printwriter create a file?
What is meant by bytecode?
Is logger a singleton?
Why are constructors used?
What is null in java?
Explain about fail safe iterators in java?
What are the disadvantages of object oriented programming?