Boolean Logic
OR is a logic gate with two inputs and one output. It gives an output of 1 when either input is 1, or when both inputs are 1. The only time an OR gate outputs 0 is when both of its inputs are 0.
| A | B | A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Read each row across: only the top row has two 0 inputs, so it is the only row with an output of 0. The other three rows each contain at least one 1, so each output is 1.
An OR gate uses inclusive OR. In everyday speech, "or" can mean one thing or the other but not both. In Boolean logic, A OR B is true when at least one of A and B is true, and it is still true when both are true.
For example, a security light comes on if its movement sensor (M) detects someone OR its manual switch (S) is on. If both happen at once, the light still comes on, so M OR S is true.
OR is written as A OR B, where A and B are the two inputs.
OCR GCSE Computer Science · Boolean Logic