Computing Library › Classical Logic Gates
Classical Logic Gates

NAND Gate

The NAND gate outputs 0 only when all inputs are 1; it is an AND followed by inversion and is functionally complete.

What it does

NAND stands for NOT-AND. Its output is the complement of AND: it is 0 only when every input is 1, and 1 in all other cases. The symbol is an AND shape with an output bubble.

Truth table

Kronos motion — when
ABA NAND B
001
011
101
110

Why it is special

NAND is a universal gate: any Boolean function can be built from NAND alone. Because CMOS pull-down networks invert naturally, NAND is also one of the cheapest and fastest gates to fabricate, which is why it is a preferred primitive.

Building other gates from NAND

Algebraic form

A NAND B equals NOT(A AND B). By De Morgan's laws this also equals NOT A OR NOT B, a useful identity when rearranging logic.

In code

python
out = 1 - (a & b)   # NAND of two 0/1 bits
out = not (a and b) # logical NAND

Its completeness and manufacturing efficiency make NAND a cornerstone of digital design.