XOR Properties
a ^ a = 0, a ^ 0 = a, commutative and associative; pairs cancel.
Decision · step 3 of 5XOR Tricks: Swap without a temporary
b = a xor b = 15 xor 9 = 6. That is the original a: (6 xor 9) xor 9 leaves 6, because the 9 cancels itself.
What you will see
Two equal rows XOR to all zeros; order does not matter.
Cost
| Space | O(1) |
|---|
How you work with it here
play it through, step one change at a time, run it on your own input, try operations in any order.
Screen readers: Each bit announces its position and value; each step announces the operation and the resulting number in binary and decimal.
Reduced motion: Bits flip with a crossfade; masks appear in place.