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.
| 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 |