I am pasting the code to find the sum of two numbers with bitwise operator. Please suggest if it can be optimized. Thanks...
public static int getSum(int p, int
I think below soln is easy to understand & simple,
public static void sumOfTwoNumberUsingBinaryOperation(int a,int b) { int c = a&b; int r = a|b; while(c!=0) { r =r <<1; c = c >>1; } System.out.println("Result:\t" + r); }