Digital logic
XOR gate
Also called: exclusive or · XOR · A ⊕ B · parity · difference detector
Definition
An XOR gate outputs 1 when its inputs are different and 0 when they are the same.
Picture it
XOR is a 'difference detector'. It is the sum bit of a binary adder, it computes parity for simple error checks, and XORing with 1 toggles a bit. A two-way staircase light switch is XOR logic.
The maths
Y = A ⊕ B = A·B̄ + Ā·B A B | Y: 00|0 01|1 10|1 11|0
| Quantity | Unit | Symbol |
|---|---|---|
| ratio | dimensionless | 1 |
Worked example
What is 0b1100 XOR 0b1010, and what is the even-parity bit for the data 1011 0010?
- Bits differ in positions 2 and 1 → 0110 = 6
- Data has four 1s; XOR of all bits = 0
- Even parity bit = 0 (total number of 1s stays even)
Answer0110 (decimal 6); parity bit 0.
✓ The 2 numbers in this answer are recomputed from scratch by an automated test.
logic tester
Logic gate tester
Y = 1
Y = A ⊕ B
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 ◀ now |
| 1 | 1 | 0 |
XOR with A = 1, B = 0 gives Y = 1.
Ideal gates: no propagation delay. 1 = true = high, 0 = false = low.
Common misconceptions
- Misconception: XOR is not the same as OR; 1 XOR 1 is 0.
- Misconception: A single parity bit catches one flipped bit but misses two.