Four gates
Inside a computer, every decision is built from logic gates. Each input and output is 1 (true, on) or 0 (false, off).
| 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 |
- AND: 1 only when both inputs are 1.
- OR: 1 when at least one input is 1.
- XOR (exclusive OR): 1 when the inputs are different. (AQA and Edexcel use XOR; OCR GCSE uses AND, OR and NOT.)
- NOT: one input, flipped.
A truth table lists every combination of inputs: n inputs need 2^n rows, counting up in binary.
Symbols and notation
AND has a flat back and a round front; OR has a curved back and a pointed front; XOR is OR with an extra curve; NOT is a triangle with a small circle.
| Words | OCR | AQA |
|---|---|---|
| A AND B | A ∧ B | A . B |
| A OR B | A ∨ B | A + B |
| NOT A | ¬A | A with a bar over it |
| A XOR B | A ⊕ B |
When you type an answer here, you can use words (AND, OR, NOT, XOR) or symbols (. + ∧ ∨ ¬ ⊕); answers are marked on their truth table.
Try it: add one gate, wire A and B into it and its output to Q, then switch the inputs.
Fill in a truth table
Go row by row. Ask: when is this gate's output 1?