Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add only with logical operation for general
public class AddLogical {
public static void main(String[] args) {
int a = 231;
int b = 35;
System.out.printf("%d + %d = %d%n", a, b, a + b);
while(b != 0){
int c = a ^ b;
b = (a & b) << 1;
a = c;
}
System.out.println(a);
}
}
@kishida

This comment has been minimized.

Copy link
Owner Author

kishida commented Jan 23, 2016

231 + 35 = 266
266
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.