I am having difficulty with bitwise addition of 2 integers without using arithmetic operators.
My logic is suppose we have to add 3+3=6
in 2's compliment addition the logic is
carry 11
(3)0000 0011
(3)0000 0011
_____________
0000 0110 (6 )
------------------------
I have understood the boolean logic. The task is now to write a
java program without using any arithmetic operators. I am allowed to use only bitwise operators.
The logic i have come up with is to XOR each bit at the end one by one in a for loop and at the end i will capture only the carry bits it should look like 0000 0110 which is the carry generated above. To accomplish this i will use the >> operator to move each bit of first and second operand and
test the bits individually. This is my vague logic. Some clues would be of great help. I thought of using arrays to convert the integer into boolean values store the bits in the arrays and use OR XOR and condition statements but seems very lenghty procedure.