Chapter 6

Subtraction

Here's the twist: your computer doesn't actually have a subtraction circuit. It only ever adds. To subtract, it plays a trick — it turns the number being subtracted into a negative number, then runs it through the exact same adder from Chapter 5.

The odometer trick

Picture an old car odometer with just two digits, wrapping from 99 back to 00. If it reads 05 and you subtract 1, it becomes 04 — obviously. But watch what happens if instead you add 99: 05 + 99 = 104, and since there are only two digits, the leading 1 falls off and you're left with... 04. Adding 99 did the exact same thing as subtracting 1. In this wraparound system, 99 behaves like −1.

Binary switches wrap around the same way — they just run out of digits much sooner. That means there's always some binary pattern that behaves like a negative number when you add it. Finding that pattern is easy: flip every switch, then add 1.

Worked example
B = 3 = 0011
flip every switch ↓
1100
add 1 ↓
1101 = 13

13 doesn't look like −3 — but watch: 3 + 13 = 16 = 10000. With only 4 switches to work with, that leading 1 has nowhere to go and falls off, leaving 0000. Adding 13 took us right back to zero — exactly what adding −3 should do. That's why 1101 is −3, as far as a 4-switch adder is concerned.

This trick is called two's complement, and it means a computer never needs a separate subtraction circuit — it converts "minus B" into "plus negative B" and reuses the adder it already has.

Try it: A − B

Build two numbers below (kept small so the results stay easy to read), then watch B get flipped, incremented, and fed into the same 4-box adder from Chapter 5 — running backwards through it, in a sense.

Interactive — Two's Complement Subtraction
Number A
= 0
Number B (being subtracted)
= 0
Input A Input B Carry Sum (output)
Step 1 — flip every switch of B
B (raw)
0000
→ flip →
flipped
1111
→ +1 →
this is −B
0000
Step 2 — add A + (−B) using the Chapter 5 adder
carry in = 0 A −B FULL ADDER place 1 A −B FULL ADDER place 2 A −B FULL ADDER place 4 A −B FULL ADDER place 8 (sign)
 

Why this works: the leftmost bit (place 8) doubles as a sign flag once we're using two's complement — if it lights up, the answer is negative, and its true size is 16 minus whatever the switches show. Any carry that spills out past the last box is simply discarded, exactly like the odometer's leading digit falling off.