Skip to content
BetterDL

NAND gate

Also called: NOT-AND gate, NAND logic gate

A logic gate that outputs 0 only when every input is 1, and 1 otherwise. It is an AND followed by a NOT, written (AB)', and it is a universal gate.

A NAND gate is short for NOT-AND: an AND with its output inverted. For two inputs, Y = . The bar covers the whole product, so you work out the AND first and then flip it.

Its truth table is AND's with every output flipped: 1 1 1 0. In words, the output is 0 only when every input is 1. A single 0 on any input is enough to make it 1.

By De Morgan's law, = : the output is 1 if A is 0 or B is 0. That reading is often the quickest way to evaluate a NAND.

NAND matters far beyond its truth table:

  • It is a universal gate. NAND alone can build NOT (1 gate), AND (2 gates) and OR (3 gates), and therefore any circuit at all.
  • In CMOS chips it is one of the cheapest gates, just four transistors. A plain AND is actually built as a NAND followed by an inverter.
  • Any sum of products can be built as two levels of NANDs, called nand nand logic.

The symbol is the AND shape with a bubble on the output.

00011
01011
10011
11100

Worked example

Example

Building OR from NANDs only

Make Y = from 2-input NAND gates.

ABY
  1. 1.

    Gate 1: tie both inputs to A. It computes = .

  2. 2.

    Gate 2: tie both inputs to B, giving .

  3. 3.

    Gate 3: NAND the two results: .

  4. 4.

    De Morgan: = = .

  5. 5.

    Three NANDs make an OR. For reference, NOT takes 1 NAND, AND takes 2 and NOR takes 4.

Common mistakes

  • Writing NAND as . That has two short bars and is NOR. NAND is , one long bar, which equals .

  • Chaining two 2-input NANDs to make a 3-input NAND. The middle inversion breaks it: the chain gives = .

  • Saying NAND is 0 when any input is 0. It's the opposite: any 0 input makes NAND output 1.

Practice NAND gate

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

NAND gate is taught in Logic Gates.