Understanding logic gates and Boolean algebra
A logic gate is the fundamental building block of digital electronics. It takes one or more binary inputs — each either 0 (LOW, false) or 1 (HIGH, true) — and produces a single binary output according to a fixed rule from Boolean algebra. Wire enough gates together in the right pattern and you get an adder, a memory cell, a CPU, or any other digital circuit. This calculator evaluates the eight standard gates for the two inputs you choose and shows the resulting output alongside the gate's complete truth table.
The eight standard gates and their formulas
- AND — Y = A · B. Output is 1 only when both inputs are 1.
- OR — Y = A + B. Output is 1 when at least one input is 1.
- NOT — Y = A′ (also written ¬A). A single-input gate that inverts its one input; input B is not used.
- NAND — Y = (A · B)′. AND followed by an inverter; output is 0 only when both inputs are 1.
- NOR — Y = (A + B)′. OR followed by an inverter; output is 1 only when both inputs are 0.
- XOR (exclusive OR) — Y = A ⊕ B. Output is 1 when the inputs differ (one 0, one 1).
- XNOR (exclusive NOR) — Y = (A ⊕ B)′. Output is 1 when the inputs match (equivalence).
- BUFFER — Y = A. A single-input gate that passes its input through unchanged; used to restore signal strength or add a small delay, not for logic.
Truth tables at a glance
For the six two-input gates, there are four possible input combinations (A,B): (0,0), (0,1), (1,0), (1,1). Reading the output column for each combination gives the full truth table:
- AND: 0, 0, 0, 1 — only one row is HIGH.
- OR: 0, 1, 1, 1 — three rows are HIGH.
- NAND: 1, 1, 1, 0 — the exact inverse of AND.
- NOR: 1, 0, 0, 0 — the exact inverse of OR.
- XOR: 0, 1, 1, 0 — HIGH exactly when A and B disagree.
- XNOR: 1, 0, 0, 1 — HIGH exactly when A and B agree.
NOT and BUFFER only have two rows, one for each value of A: NOT gives 1, 0 (inputs 0 then 1); BUFFER gives 0, 1.
Why NAND and NOR are called "universal" gates
NAND and NOR are special because either one, used by itself, can reproduce every other gate — including AND, OR, and NOT. For example, wiring both inputs of a NAND gate to the same signal produces a NOT gate, and combining NAND gates in the right pattern produces AND and OR. This is why real chips are frequently fabricated using large arrays of a single gate type: it simplifies manufacturing while still allowing any Boolean function to be built.
How to read this calculator
- Pick a gate from the Logic gate dropdown.
- Set Input A and Input B to 0 or 1 (B is ignored for the single-input NOT and BUFFER gates).
- Press Calculate to see the output, the evaluated expression, how many truth-table rows are HIGH for that gate, and the gate's standard Boolean notation.