Digital Electronics

XOR Gate: Truth Table, Boolean Expression and Parity

By CourseTron Team ·  5 min read 💬 𝕏 in f

A two-input XOR gate outputs 1 when its inputs differ and 0 when they match. Its expression is Y=A⊕B, equivalent to (NOT A AND B) OR (A AND NOT B). XOR is useful for sum bits, parity and detecting binary differences.

Reviewed 12 November 2026 · Binary examples checked with executable tests.

On this page

    What is the XOR truth table?

    XOR and its complement
    ABXORXNOR
    0001
    0110
    1010
    1101
    Two-input XOR gate symbol A B =1 Y = A⊕B Y = 1 only when A ≠ B (inputs differ) CourseTron · coursetron.com
    Two-input XOR symbol: an OR body with the extra curved input line. The "=1" qualifier is the rectangular-symbol convention for exclusive-OR.

    There are two rows with output 1: 01 and 10. The input pair 11 gives 0, which distinguishes XOR from OR. XNOR is the complement and is high for 00 and 11.

    How is the Boolean expression derived?

    Write one product term for each row that makes the output high. The 01 row contributes A′B, while 10 contributes AB′. Combining them gives:

    Y = A'B + AB' = A XOR B
    A XOR 0 = A
    A XOR 1 = NOT A
    A XOR A = 0

    These identities make XOR a selectable inverter: a control of 0 passes the data and a control of 1 inverts it. They also help check a circuit without drawing every internal transistor.

    How can four NAND gates make XOR?

    Label the shared first result before following the two branches:

    n1 = NAND(A, B)
    n2 = NAND(A, n1)
    n3 = NAND(B, n1)
    Y  = NAND(n2, n3)
    XOR from four NAND gates A B NAND 1NAND 2NAND 3NAND 4 Y n1 = (A·B)′; Y = ((A·n1)′ · (B·n1)′)′ = A⊕B CourseTron · coursetron.com
    XOR built from four 2-input NAND gates: the first NAND output feeds both second-stage gates, and a final NAND combines them into A⊕B.

    The accompanying binary tests compare this network against A XOR B for all four inputs. A matching truth table proves the ideal binary function; it does not imply equal propagation delay, area or power to a dedicated XOR cell.

    Why does an adder use XOR?

    A half adder calculates Sum=A XOR B and Carry=A AND B. For 1+1, Sum=0 and Carry=1: the two output bits represent binary 10, or decimal 2. XOR alone does not perform the complete addition because it omits the carry.

    Half adder: 1 + 1 = 10 (binary) A=1 B=1 XOR AND Sum = 0 Carry = 1 Sum = A⊕B, Carry = A·B CourseTron · coursetron.com
    Half adder in motion: two bits (both 1) stream in; XOR yields Sum = 0 while AND yields Carry = 1 — the binary result of 1 + 1 = 10.

    A full adder introduces a carry input, giving Sum=A XOR B XOR Cin. Its carry output is a separate function; see the two-half-adder construction.

    Does multi-input XOR mean exactly one input is 1?

    No. A cascade of XOR operations is high when an odd number of its binary inputs are high. With three inputs, 111 produces 1 because there are three ones. This differs from a circuit that asserts only when exactly one of three inputs is high.

    Three-input XOR is odd parity
    ABCA XOR B XOR C
    0000
    0011
    0101
    0110
    1001
    1010
    1100
    1111

    An XOR reduction can create a parity bit, but parity is not a full error-correcting code. Odd numbers of bit changes affect parity; some even-numbered changes leave it unchanged. Specify the protected data and parity convention before using it as an error check.

    Common questions

    Is XOR a universal gate by itself?

    No. Networks made solely from XOR and constants produce affine Boolean functions. They cannot express every Boolean function; NAND or NOR alone can.

    Is XOR the same as addition?

    XOR gives addition modulo 2 for one-bit values, which is the sum bit without carry. Ordinary binary addition also requires carry generation and propagation.

    Can XOR compare two words?

    Bitwise XOR marks differing bit positions. A reduction OR of those differences indicates that at least one bit differs; a zero result indicates equality for valid binary inputs.

    References and checks

    Download the functional tests and model source. These check stated binary functions; they do not establish analog timing, physical implementation, fault coverage or board behavior.