operators - Difference between bitwise inclusive or and exclusive or in java -


public class operators {      public static void main(string[] args) {                 int = 12;      system.out.println("bitwise and:"+(12&12));     system.out.println("bitwise inclusive or:"+(12|12));     system.out.println("bitwise exclusive or:"+(12^12));      } }  output:  bitwise and:12 bitwise inclusive or:12 bitwise exclusive or:0 

i understand first two, not third.

xor tells whether each bit different.

1 xor 1 = 0
1 xor 0 = 1
0 xor 1 = 1
0 xor 0 = 0

in other words "either not both"

0011 xor 0101 = 0110


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -