OR outputs 1 when at least one input is 1. It is 0 only when every input is 0.
Think of two switches side by side: closing either one, or both, lights the lamp.
OR is written with a plus sign, A + B, and an OR of literals is called a sum term. In discrete maths it is A ∨ B; in code, a || b.
The + sign is not addition:
- = 1, not 2. OR only asks whether something is 1.
- = 1 and = A (null and identity laws).
- = A (idempotent law).
This is inclusive OR: it is 1 when both inputs are 1. The "one or the other but not both" version is exclusive OR, the XOR.
In hardware this is the or gate.
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |