A Minus With No Minus Sign
The machine has no minus sign — only switches. Two's complement is the trick that lets a row of bits stand for a negative number, and turns subtraction into ordinary addition.
Every number so far has been zero or up. But programs go down too — a score that drops, a player that moves left, a countdown. They need negative numbers. And here the machine has a real problem: it has no minus sign. It has switches, and switches are only ever on or off. So how do you write −1 with nothing but bits?
The answer is one of the cleverest ideas in computing, and once you see it you’ll never quite forget it. It’s called two’s complement.
Borrow a switch for the sign
The machine can’t add a minus symbol, so it does the next best thing: it gives up half its range and spends it on negatives. In a single byte, instead of 0 to 255, a signed byte runs −128 to +127 — the same 256 patterns, just split so half of them count below zero.
The top switch (the leftmost, the 128s place) does the dividing. Off, and the number is zero or positive, exactly as before. On, and the number is negative. That top bit is now the sign bit — though, as you’ll see, it’s not only a sign; it still pulls its weight as a value.
Count backwards off the end
Here’s the trick itself. What’s one less than zero? Start at 00000000 and tick down
by one. You fall off the bottom and land at the very top: 11111111 — every switch on.
So −1 is the all-ones byte — the same pattern that, read as a plain unsigned number,
is 255.
The rule that captures it: the pattern for −n is 256 − n. For −1 that’s 255:
10 PRINT 256 - 1

The same switches, two meanings. 11111111 is 255 if you read it plainly, and −1
if you read it signed. The bits don’t change — the interpretation does.
The switches for minus five
Take −5. By the rule its pattern is 256 − 5 = 251 — and written out in switches that’s
11111011, the top bit on to mark it negative:
10 PRINT BIN 11111011

Why go to all this trouble? Addition just works
This looks like a strange way to write negatives — until you try adding one. Take 5 and add −5’s pattern, 251:
10 PRINT 5 + 251

5 + 251 comes to 256 — and 256 is 1 00000000, a one followed by eight zeros. A byte
has room for only the eight; the leading 1 falls off the top and is gone, leaving
00000000 — zero. So 5 + (−5) = 0, worked out by plain addition. That is the whole
point of two’s complement: the machine needs no separate subtraction. To subtract,
it adds the negative, and the overflow tidies itself away. One adder does both jobs.
The seam: where it wraps
Splitting the range leaves a join. Count up through the positives — …125, 126,
127 (01111111) — and add one more. The pattern becomes 10000000, whose top
switch is now on. Read signed, that’s not 128; it’s −128. Push one past the biggest
positive and you land on the biggest negative. Numbers wrap around the seam, and a
count that runs off the top reappears at the bottom — a bug worth knowing before it
bites.
When it’s wrong, see why
- The number is 256-ish away from what you expected (−1 showing as 255, −5 as 251). The byte is being read unsigned when you meant it signed, or the other way round. The bits are right; the reading isn’t. You must know which a value is.
- A positive turned huge-negative (or vice versa). You crossed the seam — counted past +127, or below −128 — and wrapped around it. Check whether the value could have run off the end of its range.
- Which bit is the sign? Always the top one (the leftmost, bit 7). Read it first: on means negative.
What you’ve learnt
- The machine writes negatives with two’s complement: the pattern for −n is
256 − n in a byte, so −1 is
11111111, −5 is11111011. - The top bit is the sign — on means negative — but the same switches can mean a positive (unsigned) or a negative (signed); the reading decides.
- The scheme exists because addition then just works: subtract by adding the negative, and the carry off the top sorts out the result. No separate subtraction.
- There’s a seam: counting past +127 wraps to −128.
What’s next
You can read a byte as bits, as hex, as a positive, as a negative. In Unit 4 we stop reading the switches and start operating on them directly — AND, OR, XOR and NOT, the bit logic that tests one switch, sets another, and combines two bytes a bit at a time.