Truth tables
A two-input truth table shows the output of an expression such as A AND B for every combination of its two inputs. Two inputs give 2 × 2 = four rows: 00, 01, 10 and 11.
AND gives 1 only when both inputs are 1. OR gives 1 when at least one input is 1, including when both are, so it is 0 only in the row where both inputs are 0.
| A | B | A AND B | A OR B |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 |
A quick check: the AND column has a single 1, in the last row, and the OR column has a single 0, in the first.
NOT works on one value, turning 1 into 0 and 0 into 1. In a two-input expression it applies to just the input or bracket it is written in front of. For A AND NOT B, work out NOT B in its own column first, then AND it with A.
| A | B | NOT B | A AND NOT B |
|---|---|---|---|
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
For example, a games console lets you play online when you are signed in (A) and you are NOT banned (B). Only the row where A is 1 and B is 0 gives 1, so that is the only situation in which you can play online.
Edexcel GCSE Computer Science · Truth tables