Four gates

Inside a computer, every decision is built from logic gates. Each input and output is 1 (true, on) or 0 (false, off).

ABA AND BA OR BA XOR B
00000
01011
10011
11110
  • 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.

WordsOCRAQA
A AND BA ∧ BA . B
A OR BA ∨ BA + B
NOT A¬AA with a bar over it
A XOR BA ⊕ 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?