Last session we could write any number in any base, provided it was not negative. Which is exactly half of the integers.
To write minus five you write a mark that is not a digit, in front of the digits. The minus sign is not part of the number system. It sits outside it.
The machine cannot do that.
It has exactly two symbols and both of them already mean something. There is no third mark to reach for.
So the sign has to be paid for out of the patterns we already have.
The leftmost bit means negative. The other seven carry the size, exactly as before.
It is how humans write numbers, so it feels obviously right. It is also the scheme that fails hardest.
| sign bit says | positive |
| magnitude | 0 |
| value | 0 |
There is no such thing as negative zero. One of these 256 patterns now means nothing at all, and worse, two different patterns have to test as equal.
Line up the columns and add, the way you have added in every base for the last four hours.
The answer should be zero. It is not even close.
So a machine using this scheme cannot just add. It has to compare the signs first, decide whether this is really a subtraction, work out which number is bigger, and only then start.
Zero, one, two, and onwards to fifteen.
Now add one more. What happens?
Fifteen is 1111. Add one and every column carries, and the carry off the end has nowhere to go, because there is no fifth wire.
You get 0000. Zero.
Which means the number line was never the right picture.
A fixed number of bits is a circle.
Step around it. Fifteen is not the top of anything. It is simply the position next to zero, on the other side.
Three hours before two o'clock is eleven o'clock. You did not go below zero to get there. You went round.
Nobody finds that confusing, and nobody needs a minus sign to say it.
So on a circle, going backwards and going forwards are the same operation.
Which means subtracting is already addition, if we are willing to read the answer differently.
1111. Fifteen.
And one step before that is 1110. Fourteen. And before that, thirteen.
The pattern one step before zero already behaves exactly like minus one. It always did. Add one to it and you get zero.
So let it mean minus one.
Fourteen means minus two. Thirteen means minus three. Cut the circle in half and read the far side as negative.
Nothing about the circle changed. We changed only what we agree the marks mean.
| pattern | 0000 |
| read unsigned | 0 |
| read signed | 0 |
Minus three is the pattern 1101, which an ordinary counter reads as thirteen. So step forward thirteen times from five and see where you land.
| steps taken | 0 of 13 |
| landed on | 0101 |
| which is | 5 |
It did not know one of those numbers was negative. It did not check a sign bit. It did not decide anything.
It added thirteen to five and threw away the carry off the end, which is the only thing it has ever been able to do.
Subtraction came out for free, from a circuit that cannot subtract,
because we chose the representation to fit the wrapping the wires already did.
Usually introduced as a rule to memorise. You have instead just derived it from the only thing a fixed row of wires can physically do.
Every pattern on the negative half of the circle starts with a one. Every pattern on the positive half starts with a zero. Check the ring if you like.
Nobody designed that.
It fell out of cutting the circle exactly in half. You get the convenience of a sign bit without paying for it, and without the two zeros.
Going backwards from zero by five is the same as going all the way round and stopping five short of the top.
So minus five is 256 − 5. Split that into 255 − 5 and then one more.
Subtracting from 255 flips every bit, because every column is one minus that bit.
Eight bits go from minus 128 up to plus 127. Not plus 128.
The two halves of the circle are exactly the same size. But the positive half has to give one of its slots to zero, and the negative half does not.
So there is a negative number you cannot negate.
Minus 128 has no positive partner in eight bits. Ask a machine for its absolute value and it hands you minus 128 back, without complaint. That is a real bug that ships, and you now know exactly why.
In Class 1 you watched a clock decide it was 1901. That is this circle, and that is this crossing.
We looked at what a finite row of wires already does when it runs off the end, and chose the meanings that made that behaviour correct.
Next session, try writing down half of something.