Skip to content

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 ⊕

Wordsa XOR b
Programminga XOR b
Mathematicala ⊕ b
Algebraa ⊕ b

2 inputs: A XOR B

A XOR B
#ABf
0FALSEFALSEFALSE
1FALSETRUETRUE
2TRUEFALSETRUE
3TRUETRUEFALSE
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
A XOR B A XOR B A B f XOR
A XOR B A XOR B A B f XOR

3 inputs (odd parity): A XOR B XOR C

A XOR B XOR C
#ABCf
0FALSEFALSEFALSEFALSE
1FALSEFALSETRUETRUE
2FALSETRUEFALSETRUE
3FALSETRUETRUEFALSE
4TRUEFALSEFALSETRUE
5TRUEFALSETRUEFALSE
6TRUETRUEFALSEFALSE
7TRUETRUETRUETRUE
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
A XOR B XOR C A XOR B XOR C A B C f XOR
A XOR B XOR C A XOR B XOR C A B C f XOR

4 inputs (odd parity): A XOR B XOR C XOR D

A XOR B XOR C XOR D
#ABCDf
0FALSEFALSEFALSEFALSEFALSE
1FALSEFALSEFALSETRUETRUE
2FALSEFALSETRUEFALSETRUE
3FALSEFALSETRUETRUEFALSE
4FALSETRUEFALSEFALSETRUE
5FALSETRUEFALSETRUEFALSE
6FALSETRUETRUEFALSEFALSE
7FALSETRUETRUETRUETRUE
8TRUEFALSEFALSEFALSETRUE
9TRUEFALSEFALSETRUEFALSE
10TRUEFALSETRUEFALSEFALSE
11TRUEFALSETRUETRUETRUE
12TRUETRUEFALSEFALSEFALSE
13TRUETRUEFALSETRUETRUE
14TRUETRUETRUEFALSETRUE
15TRUETRUETRUETRUEFALSE
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
A XOR B XOR C XOR D A XOR B XOR C XOR D A B C D f XOR
A XOR B XOR C XOR D A XOR B XOR C XOR D A B C D f XOR

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

Laws

Tools

See also

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.