why is xor of number with zero gives the number itself.
like 5^0 is 5 only???
Why is xor of number with zero gives the number itself. like 5^0 is 5 only?
As the XOR have property that 0^0=0 , 1^0=1;
Now Lets take a example : 5 ^ 0 = (1 0 1) ^ (0 0 0) =(1 0 1) which is equal to 5
Now Lets take one more example : 13 ^ 0 = (1 1 0 1 ) ^ (0 0 0 0) =( 1 1 0 1) which is equal to 13
XOR have Property
0 ^ 0 = 0
1 ^ 1 = 0
0 ^ 1 = 1
1 ^ 0 = 1