Digital logic is built from a small set of gates that each implement a Boolean function of one or two inputs. This reference shows the truth tables for all seven basic gates and lets you toggle the inputs to see every output live.
How it works
Each gate maps input bits to an output bit:
- AND —
A · B, output 1 only when both inputs are 1. - OR —
A + B, output 1 when at least one input is 1. - NOT —
¬A, the inverter; output is the opposite of A. - NAND —
¬(A · B), AND followed by an inverter. - NOR —
¬(A + B), OR followed by an inverter. - XOR —
A ⊕ B, output 1 only when the inputs differ. - XNOR —
¬(A ⊕ B), output 1 only when the inputs are equal.
NAND and NOR are universal: any circuit can be built from one of them alone.
Complete truth table for all seven gates
| A | B | AND | OR | NOT A | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 |
Where each gate appears in real circuits
AND and OR are the workhorses of combinational logic — address decoders, multiplexers, and select lines. Whenever a circuit needs “both conditions true” it usually routes through an AND gate.
NOT is the inverter that shows up everywhere: converting active-high signals to active-low, building complementary outputs on busses, and enabling de Morgan transformations.
NAND is the most physically common gate in CMOS silicon. Fabricating NAND is cheaper in terms of transistor count than AND, so many cells in a standard-cell library are NAND-based and then logically inverted where needed. A two-input NAND needs four transistors; a two-input AND needs six.
NOR plays the same universal role as NAND for NOR-based designs and appears frequently in set-reset (SR) latches — the foundational one-bit memory element is two cross-coupled NOR gates.
XOR implements the sum bit in binary adders and is the backbone of parity generators and CRC circuits. A chain of XOR gates can check whether a block of data was transmitted without a single-bit error.
XNOR is XOR with an inversion: it outputs 1 when both inputs are equal. Comparators for multi-bit equality typically AND a string of XNOR outputs — if every XNOR gate reports equal, all bits match.
de Morgan’s theorem in practice
A useful identity when simplifying circuits:
NAND(A, B) = NOT(A AND B) = NOT A OR NOT BNOR(A, B) = NOT(A OR B) = NOT A AND NOT B
This means a NAND gate with inverted inputs behaves like an OR gate, and a NOR gate with inverted inputs behaves like an AND gate — handy when you have more of one gate type available.
Tips and notes
- XOR is the sum bit of a half-adder; AND is its carry bit.
- XNOR is a single-bit equality check, used in comparators.
- The full 4-row truth table above covers every
(A, B)combination so you can cross-check a circuit by hand. - Toggle both inputs to 1 to quickly distinguish OR (output 1) from XOR (output 0) — the key practical difference between the two.