XOR gate: truth table for 2, 3 and 4 inputs (odd parity, not “exactly one”)
XOR, exclusive or, is TRUE when its two inputs differ. With three or more inputs a chain of XOR means odd parity, TRUE when an odd number of inputs are TRUE, which is not the same as “exactly one”.
The two-input table has two TRUE rows, A = TRUE, B = FALSE and A = FALSE, B = TRUE, and is FALSE when the inputs agree. The three-input table is TRUE on the rows with one or three TRUE inputs, four rows of eight; the four-input table is TRUE on the rows with one or three TRUE inputs, eight of sixteen. The engine reads A XOR B XOR C as one parity gate, and the pitfall page sets it beside the “exactly one of three” formula so you can see the row A = B = C = TRUE on which they differ.
The parser accepts XOR and ⊕. It does not accept the caret: A ^ B is XOR in C, Java, Python and JavaScript but a power in Excel and some calculators, so the parser rejects it with a repair rather than guessing. The programming notation therefore prints XOR as a word. XOR binds between AND and OR, so A XOR B OR C is (A XOR B) OR C.
XOR is the operator of difference, toggling and parity. A XOR TRUE is NOT A, which makes it a controllable inverter; A XOR A is FALSE, which is why pairs cancel in a parity chain; and the sum output of a half adder is A XOR B. A three-way light switch is the same parity function with three inputs. The XOR identities and the XOR elimination law ((A AND NOT B) OR (NOT A AND B)) are proved on their own pages.
Accepted spellings
XOR ⊕
a XOR ba XOR ba ⊕ ba ⊕ b2 inputs: A XOR B
| # | A | B | f |
|---|---|---|---|
| 0 | FALSE | FALSE | FALSE |
| 1 | FALSE | TRUE | TRUE |
| 2 | TRUE | FALSE | TRUE |
| 3 | TRUE | TRUE | FALSE |
Beginnerf is true exactly when exactly one of A and B is true (not both).
In every other case, f is false.
About the operators:
- XOR (exclusive or) is true when exactly one of its two parts is true.
Intermediatef is true exactly when exactly one of A and B is true (not both).
In every other case, f is false.
Advancedf is true exactly when exactly one of A and B is true (not both) [exclusive disjunction ⊕].
In every other case, f is false.
Formal notation: A ⊕ B
3 inputs (odd parity): A XOR B XOR C
| # | A | B | C | f |
|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | FALSE |
| 1 | FALSE | FALSE | TRUE | TRUE |
| 2 | FALSE | TRUE | FALSE | TRUE |
| 3 | FALSE | TRUE | TRUE | FALSE |
| 4 | TRUE | FALSE | FALSE | TRUE |
| 5 | TRUE | FALSE | TRUE | FALSE |
| 6 | TRUE | TRUE | FALSE | FALSE |
| 7 | TRUE | TRUE | TRUE | TRUE |
Beginnerf is true exactly when an odd number of A, B, and C are true (1 or 3 of them).
In every other case, f is false.
About the operators:
- A chain of XORs is true when an odd number of its parts are true. With three parts, all three being true also counts: it does not mean “exactly one”.
Intermediatef is true exactly when an odd number of A, B, and C are true (1 or 3 of them).
In every other case, f is false.
Advancedf is true exactly when an odd number of A, B, and C are true (1 or 3 of them) [parity: n-ary exclusive disjunction ⊕].
In every other case, f is false.
Formal notation: A ⊕ B ⊕ C
4 inputs (odd parity): A XOR B XOR C XOR D
| # | A | B | C | D | f |
|---|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | FALSE | FALSE |
| 1 | FALSE | FALSE | FALSE | TRUE | TRUE |
| 2 | FALSE | FALSE | TRUE | FALSE | TRUE |
| 3 | FALSE | FALSE | TRUE | TRUE | FALSE |
| 4 | FALSE | TRUE | FALSE | FALSE | TRUE |
| 5 | FALSE | TRUE | FALSE | TRUE | FALSE |
| 6 | FALSE | TRUE | TRUE | FALSE | FALSE |
| 7 | FALSE | TRUE | TRUE | TRUE | TRUE |
| 8 | TRUE | FALSE | FALSE | FALSE | TRUE |
| 9 | TRUE | FALSE | FALSE | TRUE | FALSE |
| 10 | TRUE | FALSE | TRUE | FALSE | FALSE |
| 11 | TRUE | FALSE | TRUE | TRUE | TRUE |
| 12 | TRUE | TRUE | FALSE | FALSE | FALSE |
| 13 | TRUE | TRUE | FALSE | TRUE | TRUE |
| 14 | TRUE | TRUE | TRUE | FALSE | TRUE |
| 15 | TRUE | TRUE | TRUE | TRUE | FALSE |
Beginnerf is true exactly when an odd number of A, B, C, and D are true (1 or 3 of them).
In every other case, f is false.
About the operators:
- A chain of XORs is true when an odd number of its parts are true. With three parts, all three being true also counts: it does not mean “exactly one”.
Intermediatef is true exactly when an odd number of A, B, C, and D are true (1 or 3 of them).
In every other case, f is false.
Advancedf is true exactly when an odd number of A, B, C, and D are true (1 or 3 of them) [parity: n-ary exclusive disjunction ⊕].
In every other case, f is false.
Formal notation: A ⊕ B ⊕ C ⊕ D
The common slip
Using a chain of XOR for “exactly one of several”. A XOR B XOR C is TRUE when all three are TRUE, because three is odd. The worked example shows the correct three-case formula and the row on which the two part.
Questions
Is XOR commutative and associative?
Yes, both, which is why the chain needs no brackets and reads the same in any order. The identities page proves A XOR A = FALSE, A XOR FALSE = A and A XOR TRUE = NOT A.
What is XOR in terms of AND, OR and NOT?
(A AND NOT B) OR (NOT A AND B), one term per TRUE row. The equivalent product-of-sums form is (A OR B) AND (NOT A OR NOT B), and the normal-form converter produces both.
Related
Guides
Worked examples that use it
- Odd parity of three inputs: A XOR B XOR C
- Exactly one of three: why XOR is the wrong tool
- Half adder sum: A XOR B
- Half adder carry: A AND B
- Full adder sum: A XOR B XOR Cin
- Full adder carry-out: (A AND B) OR (Cin AND (A XOR B))
Laws
- XOR identities: A XOR FALSE = A, A XOR TRUE = NOT A, A XOR A = FALSE
- XOR elimination: A XOR B = (A AND NOT B) OR (NOT A AND B)
- Minterm expansion: the canonical sum of products (Σm)
Tools
- Truth table generator: any Boolean expression, up to 12 variables, with intermediate columns
- Logic circuit generator: Boolean expression to gate diagram (SVG)
See also
- XOR identities: A XOR FALSE = A, A XOR TRUE = NOT A, A XOR A = FALSE
- XOR elimination: A XOR B = (A AND NOT B) OR (NOT A AND B)
- XOR of three inputs is odd parity, not “exactly one”
- ^ means XOR in C, Java and Python, not AND or power
- Odd parity of three inputs: A XOR B XOR C
- Half adder sum: A XOR B
- Staircase light with three switches: A XOR B XOR C
- Lesson 2: XOR: exclusive OR and parity (beginner, 10 min)
Operators and gates
Generated from the Tangibool engine, semantics tangibool-semantics/1, engine 1.0.0, build . Every table, map, simplification and verdict on these pages was computed by the Tangibool engine when the site was built, and every claim was re-checked by the same exact checker the app uses. Limits are stated where they apply. © 2026 Foreranger LTD.