AlgoScope

XOR Properties

MathematicsbeginnerBit Manipulation

a ^ a = 0, a ^ 0 = a, commutative and associative; pairs cancel.

Decision · step 3 of 5XOR Tricks: Swap without a temporary
15061

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.

Open in the player →or start at step 3

What you will see

Two equal rows XOR to all zeros; order does not matter.

How xor tricks works →

Cost

SpaceO(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.

Before this

Leads to

Topics that need this one first.

Taught by the same lesson

XOR Tricks covers these too, in the same run.