Bitwise Multiply and Add in Java
I have the methods that do both the multiplication and addition, but I'm just not able to get my head around them. Both of them are from external websites and not my own: public static void bitwiseMultiply(int n1, int n2) { int a = n1, b = n2, result=0; while (b != 0) // Iterate the loop till b==0 { if ((b & 01) != 0) // Logical ANDing of the value of b with 01 { result = result + a; // Update the result with the new value of a. } a <<= 1; // Left shifting the value contained in 'a' by 1. b >>= 1; // Right shifting the value contained in 'b' by 1. } System.out.println(result); } public static