ToolSphere
Back to all articles
electronics

Logic Gates: Truth Tables and Examples

2026-10-206 min read

Try it: free Logic Gate Simulator

Flip logic gate inputs and watch the output change

Open →

A logic gate takes one or two binary inputs (0 or 1, low or high voltage) and produces one output according to a fixed rule. Every digital circuit, from a doorbell timer to a CPU, is built from a handful of these.

The seven gates

Gate Expression Output is 1 when…
AND A · B both inputs are 1
OR A + B at least one input is 1
NOT A̅ the input is 0
NAND (A · B)̅ not both inputs are 1
NOR (A + B)̅ both inputs are 0
XOR A ⊕ B the inputs differ
XNOR (A ⊕ B)̅ the inputs are the same

All the truth tables in one

A B AND OR NAND NOR XOR XNOR
0 0 0 0 1 1 0 1
0 1 0 1 1 0 1 0
1 0 0 1 1 0 1 0
1 1 1 1 0 0 0 1

NOT has one input: NOT 0 = 1, NOT 1 = 0.

Each "N" gate is its partner with the output flipped: compare the AND and NAND columns, OR and NOR, XOR and XNOR. In a circuit symbol, that inversion is the small circle (the "bubble") on the output.

Why NAND is universal

Any logic function can be built from NAND gates alone, which is why chips have historically been full of them: one cheap, fast gate type, repeated.

To get Wire NAND gates like this
NOT A A NAND A
A AND B (A NAND B) NAND (A NAND B)
A OR B (A NAND A) NAND (B NAND B)
A XOR B 4 NANDs: let N = A NAND B; then (A NAND N) NAND (B NAND N)

Check the OR line with A = 0, B = 1: A NAND A = 1, B NAND B = 0, and 1 NAND 0 = 1. Correct. NOR is universal too, by the mirror-image construction.

De Morgan's laws

The two rules that let you move between AND and OR forms:

(A · B)̅ = A̅ + B̅      NAND = OR of the inverted inputs
(A + B)̅ = A̅ · B̅      NOR  = AND of the inverted inputs

They're how you redraw a circuit in whichever gate type you have, and the first step in most simplification exercises.

A half adder from two gates

Adding two single bits gives a sum bit and a carry bit:

A B Sum (A XOR B) Carry (A AND B)
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

One XOR and one AND: 1 + 1 = binary 10, sum 0 carry 1. Chain two half adders and an OR gate and you have a full adder, which adds a carry-in as well; chain 32 or 64 full adders and you have the adder in a processor.

Gates with more inputs

AND, OR, NAND and NOR extend naturally: a 3-input AND is 1 only when all three are 1. A multi-input XOR is 1 when an odd number of inputs is 1, which makes it the parity checker used in error detection.

Common mistakes

  • Confusing NOR and XNOR. NOR is 1 only for 0, 0; XNOR is 1 for 0, 0 and 1, 1.
  • Treating OR as exclusive. Ordinary OR is 1 when both inputs are 1; XOR is the exclusive one.
  • Applying De Morgan without flipping the operator. Inverting the inputs alone isn't enough; AND becomes OR and vice versa.

Try it

The logic gate simulator lets you flip the inputs of AND, OR, NOT, NAND, NOR and XOR and watch the output. To build the truth table of a whole expression, use the truth table generator, then simplify it with the Karnaugh map solver.

For a related walkthrough, read Truth Tables: Reading Boolean Logic.

Looking for other tools?

Explore ToolSphere Homepage →