Detailed Explanation (BIt Manipulation and Binary Arithmetic) + Java Code
Bitwise Operators:\n XOR: ^\n And: &\n Left Shift: << n  (Shifts a binary value n digits to the left by adding zeros at the end.\n\nConceptual: We first need to
# Bitwise Operators:\n* XOR: ^\n* And: &\n* Left Shift: << n  (Shifts a binary value n digits to the left by adding zeros at the end.\n\nConceptual: We first need to come up with a variable called carry. Carry will record the component of the addition that needs to be shifted. Here is an example\n\n**First, let\'s look at what happens when we add binary digits that are identical to one another:**\n* adding 111 + 111 will result in 1110 // 7 + 7 = 14\n* adding 1100 + 1100 = 11000  //12 + 12 = 24\n* adding 101 + 101 = 1010 //5 + 5 = 10\nWe can logically reduce adding identical binary digits using the left shift operator. This means that for any identical binary digits a, and b the sum will always be a << 1 which is the same as b << 1\n\n**Let\'s Look at adding Binary Digits that are opposites of each other**\n* 101 + 010 = 111 //\n* 1001 + 0110 = 1111 // \nWe can see that adding binary digits that are the opposites of each other are as simpl as taking\na XOR b which gives us the answer.\n\nSo the task of this question is to simply separate the identical components of the two digits with the complementary components. Shift the identical component to the left by one. Then add it to the separate component.\n\nThis is accomplished with the following code\n\n```\npublic sum(int a, int b) {\n\twhile (b != 0) {\n\t//filter out identical component\n\tint carry = a & b;\n\t//filter out complementary component\n\ta = a ^ b;\n\t\n\t//shift b to the left the common components. and assign it to b\n\t//on the next iteration there will be fewer and fewer common components\n\t//and gradually b will converge to 0 conce we have shifted the integer left \n\t//the appropriate amount of times. \n\tb = carry << 1;\n\t}\n\treturn a;\n}\n```\n\n\n\n\n
['Bit Manipulation', 'Java']