Logic Gates · Cambridge syllabus 10.1, 10.2 · Lesson 5 of 5
XOR
A two-input XOR gate outputs 1 when the inputs differ and 0 when they match. Its behaviour differs from OR only when both inputs are 1.
By the end, you can
- Understand the XOR gate.
- Construct an XOR truth table.
- Explain how XOR differs from OR.
Exclusive OR
An XOR gate, exclusive OR, gives 1 when its two inputs are different, and 0 when they are the same.
Its truth table is: 0 and 0 give 0; 0 and 1 give 1; 1 and 0 give 1; 1 and 1 give 0. The single difference from an ordinary OR gate is the last row, and that one row is the whole point.
It captures the everyday meaning of or: one or the other, but not both. A room light controlled by switches at each end of a corridor behaves this way — changing either switch changes the light, and having both up is the same as having both down.
Its symbol is the OR shape with a second curved line across the input side. In a logic expression it is written in words: X = A XOR B. The syllabus also calls it EOR.
A useful way to say it is that XOR outputs 1 when the inputs disagree, which is why it is the gate used to check whether two bits are different.
Worth remembering
- XOR gives 1 when the inputs are different and 0 when they are the same.
- It differs from OR in one row only: 1 with 1 gives 0.
- It outputs 1 exactly when the two inputs disagree.
Worked example
0 XOR 1 = 1, while 1 XOR 1 = 0.
Practice
Warm-up · not marked
Check your understanding
Answer in your own words, then compare with the worked answer. Nothing here is saved or scored.
Worked answer
0, 1, 1, 0.
Check your method, units and explanation against it.
Marked practice
Set 1 of 4 · easiest first · Checked as you go, with the worked answer. Sign in or create a free account to save your progress.