Created
January 23, 2016 17:13
-
-
Save kishida/af8c39ad57104db5774e to your computer and use it in GitHub Desktop.
Add only with logical operation for general
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Author
kishida
commented
Jan 23, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment