Boolean logic and truth tables
Computer Science · Key Stage 3 · The School
Three operators
Boolean logic works on values that are only TRUE or FALSE. AND is true only when both inputs are true. OR is true when at least one is true. NOT flips a value. These map onto ordinary speech imperfectly — everyday "or" often means one or the other but not both, whereas Boolean OR includes both, and that gap causes real bugs.
Truth tables
A TRUTH TABLE lists every possible combination of inputs and the output for each. Two inputs give four rows, three inputs give eight — the number of rows doubles with each input. Building the table is how you check a condition does what you intended, rather than what you assumed while writing it.
From logic to hardware
These operations are built physically as LOGIC GATES from transistors, and combinations of gates perform arithmetic. A processor is, at bottom, a very large arrangement of them. So the same AND you write in a program is the same AND etched into silicon — which is why this topic sits at the join between programming and hardware.
A OR B. Row 1: A false, B false → false. Row 2: A true, B false → true. Row 3: A false, B true → true. Row 4: A TRUE, B TRUE → TRUE. That last row is where everyday English misleads: "tea or coffee" means one, but Boolean OR means at least one. The version that excludes both-at-once is XOR, and it has its own gate precisely because it is a different question.