LogicGates.org Open the simulatorSimulator

NAND gate

The inverse of AND, and enough to build everything else.

Truth table

ab Q
0 0 1
0 1 1
1 0 1
1 1 0

At a glance

Boolean expression
¬(a ∧ b)
Engineering notation
(a · b)'
Inputs
Two or more
Output is high when
any input is low

How the NAND gate behaves

A NAND gate outputs 0 only when all of its inputs are 1, and 1 in every other case. It is an AND gate with the output inverted, which is where the name comes from: Not AND.

NAND is functionally complete: every other gate can be built from NAND gates alone, so an entire processor could in principle be made of nothing else. That is not just a curiosity. In CMOS a NAND and a NOR both take four transistors, but the NAND puts its series devices on the fast side and its slow ones in parallel, so for the same drive strength it ends up smaller and quicker. That is why real chips are dominated by it. Only the inverter, at two transistors, is smaller still.

Building it from other gates

Each of these is equivalent to the NAND gate. Paste any of them into the simulator with ctrl+E to see the circuit.

Construction Expression Equals
NOT from NAND !(a & a) !a
AND from NAND !(!(a & b) & !(a & b)) a & b
OR from NAND !(!(a & a) & !(b & b)) a | b
De Morgan form !a | !b !(a & b)

Reference card

The symbol in both standards and the truth table on one image, for notes or a slide.

NAND gate reference: ANSI and IEC symbols, the boolean expression ¬(a ∧ b), and the full truth table Click to download the NAND reference card

Where the NAND gate is used

  • Building any other gate, which is why NAND is the workhorse of real logic families.
  • Cross-coupling two NAND gates gives an SR latch, the simplest circuit that remembers a bit.
  • Flash memory cells are arranged in a NAND configuration, which is where the name NAND flash comes from.
  • Replacing an AND followed by a NOT with a single, faster gate.

In the simulator

NAND is in the Logic menu and takes a configurable number of inputs. Try rebuilding a half adder from NAND gates alone; it takes five.

Open the simulator

Questions about the NAND gate

Why is NAND called a universal gate?

Because NOT, AND and OR can all be built from NAND gates alone, and those three are enough to express any boolean function. So any circuit at all can be rewritten using only NAND gates. NOR is universal for the same reason.

What is the difference between NAND and NOR?

NAND is an inverted AND: it outputs 0 only when every input is 1. NOR is an inverted OR: it outputs 1 only when every input is 0. So NAND is 1 on three of its four rows and NOR on just one. Invert every input and the output of a NAND and you get a NOR, which is De Morgan's law in gate form. Both are universal.

How do you make a NOT gate from a NAND gate?

Tie both inputs together, or hold one input high. A NAND with both inputs fed by the same signal outputs the inverse of that signal.

The other gates