XOR follows its own small set of rules. Four with a constant or a repeated input are worth memorizing:
- = A. XOR with 0 passes A through.
- = . XOR with 1 inverts A.
- = 0. A signal never differs from itself.
- = 1. A signal always differs from its complement.
The first two make XOR a controlled inverter: one input decides whether the other passes straight through or is flipped. Processors use a row of XORs sharing one control line to invert a whole number at once, which is a step in subtraction.
XOR is also commutative and associative, so you can reorder and regroup freely: means the same however you bracket it.
Put those together and you get self-cancelling: XORing the same value twice undoes it, = A. That is why XOR is used for simple masking and toggling.
Rules involving inversion:
- = = . Inverting either input, or the output, gives XNOR.
- = . Inverting both inputs changes nothing.