AND outputs 1 only when every input is 1. If any input is 0, the result is 0.
Think of two switches in series on one wire: the lamp lights only if both are closed.
AND is written like multiplication, AB or A·B, and it behaves like multiplying 0s and 1s: 1 · 1 = 1, and anything times 0 is 0. That is why an AND of literals is called a product term. In discrete maths it is written A ∧ B; in code, a && b.
Useful facts:
- An AND of literals is 1 for exactly one combination of the variables it mentions. is 1 only when A = 1 and B = 0.
- = A and = 0 (identity and null laws).
- It works for any number of inputs: needs all four.
In hardware this is the and gate. Together with OR and NOT it can build any boolean function.
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |