An XOR gate (exclusive OR) outputs 1 when its inputs are different: one is 1 and the other is 0. When both are 0 or both are 1, it outputs 0. It is written , shown as A ⊕ B, and typed with ^.
Compare it with OR. The two agree in rows 00, 01 and 10. They differ only in row 11, where OR gives 1 and XOR gives 0. "Exclusive" means one or the other, but not both.
Using only AND, OR and NOT, XOR is : one term picks out row 01, the other row 10.
Why XOR shows up everywhere:
- Adding bits. The sum bit of 1-bit addition is XOR (0, 1, 1, 0), so XOR sits at the heart of every half adder and full adder.
- Controlled inversion. = A and = , so one input can decide whether the other is flipped. See xor identities.
- Parity. A multi-input XOR outputs 1 when an odd number of inputs are 1, which is how parity bits are made.
- Comparing. XOR is 1 exactly where two bits disagree.
The symbol is the OR shape with an extra curved line behind the inputs.