Why this matters
Deep down, a computer only ever shuffles 1s and 0s. Every calculation it does is built from a few tiny circuits that follow simple yes/no rules. Once you can read these rules, you can predict exactly what the machine will output. You've also seen the foundation that addition and everything else is built on.
The idea
In a computer, 1 means true and 0 means false. A logical operation combines such values, and a logic circuit carries one out. We describe a circuit with a truth table: every possible input combination and the output it gives. Three basic gates:
- AND gate: outputs 1 only when all inputs are 1.
- OR gate: outputs 1 if at least one input is 1.
- NOT circuit: outputs the opposite of its single input.
| A | B | AND | OR |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 |
NOT is simpler: input 0 gives 1, input 1 gives 0.
Combine these gates and you get useful circuits. A half adder adds two single-digit binary numbers, producing a sum S and a carry C. For example, 1 + 1 = 10, so C=1 and S=0.
Picture it
flowchart LR
A[Input A = 1] --> G{AND gate}
B[Input B = 0] --> G
G --> X[Output X = 0]
Worked example
What does an AND gate output for inputs A=1, B=0? AND needs all inputs to be 1, and B is 0, so the output is 0. An OR gate with the same inputs outputs 1, because at least one input (A) is 1. Now feed A=1 into a NOT circuit: it flips it, giving 0. In a half adder with A=0 and B=1, exactly one input is 1, so the sum S=1 and the carry C=0.
Your turn
Try the practice: read AND, OR, and NOT outputs, match each gate to its rule, and sort input combinations by what an AND gate outputs.
Recap
- 1 = true, 0 = false; a truth table lists every input/output combination.
- AND = 1 only if all inputs are 1; OR = 1 if any input is 1; NOT = the opposite.
- Combine gates to build adders. A half adder gives a sum and a carry.