If we do 0^n
we get n
as the output, but why so? If n is int
then does the bitwise operation occurs on 2^31
bits and then we get the number n as the output itself?
How do we get 0^n as n?
@raghav6 The result of XOR is 1 if the two bits are different. So XOR of 0 with any number n will always give n as output. Yes…the bitwise operation occurs on all the bits that data type can hold.
Consider unsigned char a = 5, b = 9;
So a = 5(00000101) and b = 9(00001001)
a^b= (00001100)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.