SECTION 02 / 6

Logic Gates — NOT, AND, OR and Friends

3 min read
On this page 4 headings

Start here A lift door should open only if the lift has stopped AND someone pressed the button. A fan should run if the switch is on OR the timer is on. A night lamp should glow when it is NOT bright outside. These three words, AND, OR and NOT, are the basic building blocks of every computer.

The three basic gates

Each gate’s symbol, its rule, and its full truth table.
Each gate’s symbol, its rule, and its full truth table.
Open image ↗
The basic gates
Gate Written as Read as Output is 1 when…
NOT A‾\overline{A} (or A′) “not A” A is 0 (it flips the input)
AND A⋅BA \cdot B (or AB) “A and B” both A and B are 1
OR A+BA + B “A or B” at least one of A, B is 1

Careful: in Boolean algebra, + means OR, not addition. So 1 + 1 = 1 (not 2).

Lift door: AND. Fan: OR. Night lamp: NOT.
Lift door: AND. Fan: OR. Night lamp: NOT.
Open image ↗
AND, OR, NOT in daily life

The other gates you’ll meet (and in exams)

Gate Formula Output is 1 when… Memory trick
NAND (A⋅B)‾\overline{\left(A \cdot B\right)} NOT both are 1 AND, then flip
NOR (A+B)‾\overline{\left(A + B\right)} both are 0 OR, then flip
XOR A⊕BA \oplus B the inputs are different “one or the other, not both”
XNOR (A⊕B)‾=A⊙B\overline{\left(A \oplus B\right)} = A \odot B the inputs are the same an “equality checker”
NAND and NOR are AND and OR with a small circle (the flip) on the output. XOR adds an extra curve.
NAND and NOR are AND and OR with a small circle (the flip) on the output. XOR adds an extra curve.
Open image ↗
More gates

Full truth table for 2 inputs:

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

Two useful facts (they come up a lot):

  • XOR with many inputs = 1 when an odd number of inputs are 1.
  • XNOR of two inputs = 1 when A=BA = B. That’s a 1-bit comparator.

Order of operations (precedence)

What does W⋅X‾+Y⋅ZW \cdot \overline{X} + Y \cdot Z mean? Just like × before + in normal maths:

  1. NOT first (highest)
  2. then AND
  3. then OR (lowest)

So W⋅X‾+Y⋅Z=W \cdot \overline{X} + Y \cdot Z = (W AND (NOT X)) OR (Y AND Z).

In one line: NOT flips, AND needs all 1s, OR needs at least one 1. NAND and NOR are their flipped versions, XOR checks “different” and XNOR checks “same”. Order: NOT, then AND, then OR. Exam words: logic gate, NOT (inverter), AND, OR, NAND, NOR, XOR, XNOR, complement, precedence, bubble.


Quick check

In Boolean algebra, what is 1 + 1? 1 (the + means OR).
A=1,B=1A = 1 , B = 1. Give NAND, NOR, XOR, XNOR. NAND 0, NOR 0, XOR 0, XNOR 1.
Three inputs 1, 1, 1 go into an XOR. Output? 1, because three is an odd number of 1s.
What does A+B⋅CA + B \cdot C mean? A OR (B AND C). AND is done before OR.
YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑