# bitwise XOR

Bitwise XOR or bitwise exclusive OR is a bit-level operation on two binary values which indicates which bits are set in only one value. For each position $i$, if the bit $d_{i}$ in one value is 1 and the other is 0, then $d_{i}$ of the result is 1, otherwise it’s 0. If both input $d_{i}$ are 1, the output $d_{i}$ is 0. then For example, given 50 and 163 in two unsigned bytes, a bitwise XOR returns 145.

 XOR = 0 0 1 1 0 0 1 0 1 0 1 0 0 0 1 1 1 0 0 1 0 0 0 1

Given a Mersenne number of the form $2^{k}-1$ (where $k$ is the bit size of the data type in use, e.g., 8 for bytes, 16 for words, 32 for double words, etc.) and some smaller integer $n$, XORing that Mersenne number with $n$ has the same effect as performing a bitwise NOT on $n$. Or, given $m$ and $n$, XORing them has the same effect as $m-n$ (subject to some caveats about the sign bit, or if the values are unsigned, the effect is then the same as $|m-n|$). XORing two values that are the same gives 0.

Title bitwise XOR BitwiseXOR 2013-03-22 17:02:52 2013-03-22 17:02:52 PrimeFan (13766) PrimeFan (13766) 4 PrimeFan (13766) Definition msc 11A63 BitwiseAND BitwiseOR BitwiseNOT