[Tutor] xor
Paul Sidorsky
paulsid@shaw.ca
Wed, 05 Jun 2002 11:43:41 -0600
Terje Johan Abrahamsen wrote:
> What does really xor do? I tried an example,
> >>> 30^76
> 82
>
> ^ means xor if I am completely wrong. I don't see any connection between the
> numbers. Can anyone explain?
XOR works on the binary level. x XOR y is true if and only if x != y,
where x and y are binary digits (bits). So if we convert your example
to binary, it makes sense:
0011110 = 30
^ 1001100 = 76
--------------
1010010 = 82
--
======================================================================
Paul Sidorsky Calgary, Canada
paulsid@shaw.ca http://members.shaw.ca/paulsid/