Computers make decisions with Boolean values: TRUE or FALSE, stored as 1 or 0. Logical operators combine them.
| Operator | Output is TRUE (1) when … | In words |
|---|
| AND | Both inputs are 1 | "A and B" |
| OR | At least one input is 1 (either or both) | "A or B, or both" |
| NOT | The input is 0 (it reverses its one input) | "not A" |
| XOR (exclusive OR) | Exactly one input is 1 (the inputs are different) | "A or B, but not both" |
Truth tables list every possible combination of inputs and the output for each.
| A | B | A AND B | A OR B | A XOR B |
|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |