Boolean Logic
An AND gate is a logic gate that combines its inputs into a single output. With the usual two inputs, its rule is strict: the output is 1 only when both inputs are 1, and a single 0 at either input forces the output to 0.
Think of a bike lock that needs a key turned and a code entered before it releases. Turning the key alone is not enough, and typing the code alone is not enough — both things must happen together. Set key turned = 1 and code entered = 1: only then does the lock give an output of 1 and open.
Two inputs give four possible combinations, so the truth table has four rows. Just one of those rows produces an output of 1 — the last one, where A and B are both 1:
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
AND is written as A AND B. The result is true only when every condition joined by AND is true, so the answer is 0 the moment any single condition is false. If you joined three conditions as A AND B AND C, the output would be 1 only in the one case where all three are 1.
An AND gate is stricter than an OR gate: a single 1 at one input is never enough to satisfy it, however the other input is set.
OCR GCSE Computer Science · Boolean Logic