Bitwise logic Operations

I see there are (bitwise AND) and (bitwise OR):

int b=41; int a=33; int c = a&b; println(binary(b,8)); println(binary(a,8)); println(binary(c,8)); int d = a | b;

Are there any ways of combining these with (!) to make nor and nand operations ? ( other than using a charAt loop). What I want to do is XOR two numbers to invert one to its binary opposite.


XOR 11111111

      01010101  result

something like b = ! b. (which doesn't work). Thinking maybe the syntax is just eluding me. Seems this must exist in Java.


Sign In or Register to comment.