1-min guide

Logic circuits and truth tables

Inside a computer, huge numbers of tiny parts (logic gates) that take 0s and 1s and return 0 or 1 are combined. Every calculation and decision comes down to these combinations.

Reading time: about 1 min

More in the 5-min version →

In the game, this was light switches in a roomPlay “Light Up the Room”

In the gameIn real IT
Switch on / off1 and 0
Series wiringAND
Parallel wiringOR
Stair switches (top and bottom)XOR
Fridge door switchNOT
Switch-and-light tableTruth table
ANDA B → out0 0 → 00 1 → 01 0 → 01 1 → 1ORA B → out0 0 → 00 1 → 11 0 → 11 1 → 1XORA B → out0 0 → 00 1 → 11 0 → 11 1 → 0NOTA → out0 → 11 → 0
The four basic gates (MIL symbols) and their truth tables. A green 1 marks a row where the output is 1

The four basic gates

AND and OR with their results flipped by NOT are called NAND and NOR. You can build any circuit by combining NAND gates alone.

A truth table lists every pattern

A truth table lists every combination of inputs and the output for each. Two inputs give 4 rows, three give 8 (2 to the power n). If two tables are exactly the same, the circuits do the same job even if their insides differ.

Addition can be built from gates

ABS (lower digit)C (carry)
0000
0110
1010
1101

In 1-digit binary addition, the S column is the same as XOR and the C column the same as AND. This circuit is called a “half adder”; join two and add an OR, and you get a “full adder” that can add a carry too. A CPU’s arithmetic is rows of these.

How the FE exam asks it

Common questions ask you to read a circuit diagram (MIL symbols) and give the output, or to pick the logical expression that matches a truth table. In expressions, AND is written A·B, OR as A+B, NOT as a bar over A, and XOR as A⊕B.

Summary
  • AND = both 1, OR = either 1, XOR = 1 if different, NOT = flip
  • A truth table lists every input pattern (n inputs → 2 to the power n rows)
  • Addition is built from XOR (lower digit) and AND (carry)
Go further: 5-min deep diveLogic circuits in depth: De Morgan, NAND and bit masksWhy NAND alone can build anything, De Morgan’s laws (an exam favorite), and the AND that subnet masks use every day.Read the 5-min version →