XOR vs OR: inclusive or exclusive?
OR and XOR differ in exactly one row of the truth table. OR (inclusive or) outputs 1 when at least one input is 1, including when both are. XOR (exclusive or) outputs 1 only when the inputs differ, so when both inputs are 1 it outputs 0. In Boolean form, A OR B = A + B, while A XOR B = A'B + AB'. XNOR is the inverse of XOR: it outputs 1 when the inputs are equal. If either input being 1 is enough, it is OR; if it must be one or the other but not both, it is XOR.
What each gate is used for
OR combines conditions: an alarm that sounds when either of two doors opens, an interrupt raised by any of several devices, an address range made of several decodes. XOR detects difference: it is the sum bit of a half adder (1 + 1 = 10, so the sum digit is 0), the heart of parity generators, a controlled inverter (A XOR 1 = NOT A), and, as XNOR, the bit-equality test inside comparators. In CMOS an OR gate is a NOR plus an inverter, 6 transistors; an XOR takes about 8 with transmission gates, or 12 as a fully complementary gate.
Try both live in digiwleea
Toggle the inputs of the live OR gate, XOR gate and XNOR gate, then build them from transistors: the CMOS OR and CMOS XOR, or XOR from four NAND gates. The XOR lesson explains why XOR needs more transistors than OR.
OR, XOR and XNOR truth table
| A | B | A OR B | A XOR B | A XNOR B |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 1 | 0 | 1 |
No sign-up is needed to start: open the lab and place your first transistor, or read the free theory course. The account (and the AI tutor) are optional.
More comparisons: Digital logic concepts compared
See for yourself: build a logic gate from transistors in the simulator, then follow the path from sand to an 8-bit CPU.
Open the digiwleea lab →Frequently asked
What is the difference between XOR and OR?
OR outputs 1 when one or both inputs are 1. XOR outputs 1 only when exactly one input is 1, so for inputs 1 and 1, OR gives 1 and XOR gives 0.
What is 1 XOR 1?
0. XOR outputs 1 only when its inputs differ.
Is XOR the same as addition?
For single bits it is addition without the carry: 1 + 1 = 10 in binary, and XOR gives the 0 digit while AND gives the carry, which is exactly a half adder.
What is XNOR?
The inverse of XOR: XNOR outputs 1 when its inputs are equal (both 0 or both 1), so it tests whether two bits match.