How computers work at the lowest level: binary numbers, logic gates, and circuits that remember. Press play on any sketch to watch it happen.
1 Binary and number systems
Computers store everything as bits, because a circuit can reliably be on or off. Each binary digit is worth double the one to its right, just as each decimal digit is worth ten times.
Bit and byte: a bit is 0 or 1, and a byte is 8 bits.
Hexadecimal: one hex digit stands for 4 bits, so 1101 is D.
Two's complement: the standard way to store negative numbers: flip the bits, then add 1.
Overflow: an 8-bit unsigned value holds 0 to 255. 255 + 1 wraps round to 0.
Rule of thumb: Learn the powers of two up to 1024 by heart. They appear everywhere in computing.
2 Logic gates and adders
Gates are tiny circuits that make decisions from bits. Combine a few and you can add numbers, which is the first step towards a full processor.
AND: output is 1 only if both inputs are 1.
OR: output is 1 if any input is 1.
XOR: output is 1 if the inputs differ.
NOT: flips the input.
Half adder: XOR gives the sum bit, and AND gives the carry.
Logic diagram
1/4 0 + 0: nothing is on, so both outputs stay 0.
A
B
Sum
Carry
0
0
0
0
0
1
1
0
1
0
1
0
1
1
0
1
Rule of thumb: Truth tables never lie. When a circuit confuses you, write one out.
3 Flip-flops and counters
Logic gates alone forget everything. A flip-flop stores one bit, and it updates only on a clock edge. Group them and you get registers, counters and memory.
Clock: a steady signal that tells the whole circuit when to change.
D flip-flop: copies D to Q on the rising clock edge, then holds it.
Register: a group of flip-flops that stores a number.
Counter: a register that adds one on each clock tick.
Timing diagram
1/4 D changes to 1, but the clock is low, so Q ignores it.
Rule of thumb: Combinational logic works out the next value. Flip-flops decide when it takes effect.