Demo 1.3: Arithmetic Without a Minus Sign
The previous two demonstrations were about writing quantities down. This one is about doing something with them, and it runs into a problem almost immediately.
A circuit has two voltages. It has no third symbol to spend on a minus sign, no separate place to record that a value is negative, and no way to mark a number as special. Whatever “negative” is going to mean, it has to be built out of the same bits that are already carrying the number, and it has to be built in a way that a row of identical gates can act on without knowing what it is doing.
That constraint is much tighter than it looks, and it is the reason this topic has an answer that nobody guesses first time.
Carry, and then a harder problem
Section titled “Carry, and then a harder problem”Binary addition itself is not difficult. Work from the right, add what is in each column, write down what fits and carry what does not. There are four cases and three of them are dull: 0 + 0 is 0, 0 + 1 is 1, 1 + 0 is 1. The fourth is 1 + 1, which is 2, and 2 will not fit in one bit. In binary it is 10, so you write 0 and carry 1.
Everything awkward about adders comes from that one line, and the first tab is really an excuse to watch a carry appear and travel along a row of columns.
The harder problem starts on the second tab. Spending the top bit on a sign is the idea everyone has, it is perfectly readable, and it very nearly does not work at all. Seeing precisely how badly it fails is what makes the answer on the third tab feel inevitable rather than arbitrary.
How to use it
Section titled “How to use it”Adding bits starts at one bit wide and goes up to four, with the answer allowed a fifth bit when it needs one. Set the two numbers with the bit toggles or use the presets, then press Do it column by column and step through the sum one column at a time. The rule in use lights up in the panel underneath as you go. Start at one bit and press 1 + 1, because the whole difficulty of the subject is visible there.
A bit for the sign takes the obvious approach to negative numbers and tests it honestly. Choose two values, watch them added as ordinary binary, and read the verdict. There is a table of all sixteen patterns showing the two different zeros, and a panel that has tried every pair in range and counted how many come out right.
Two’s complement keeps the sign bit and gives it a negative weight. The weight strip at the top can be clicked, and every pattern of bits is a legal number. There is a stepper that shows the invert-and-add-one procedure a line at a time, the full sixteen-pattern table again, and an addition panel whose operands are deliberately fenced in so that nothing here overflows.
Subtraction is addition does a − b by negating b and adding. Step through it to see the negation happen before the sum. There are presets at four and six bits, including both of the worked examples from the reading.
Binary Arithmetic and Negative Numbers
Adding with carries, two attempts at writing a negative number, and why no computer has a subtractor.
Walkthrough
Section titled “Walkthrough”Step 1: Start with the smallest possible adder
Section titled “Step 1: Start with the smallest possible adder”Open Adding bits, set the width to 1 bit and press 1 + 1.
One bit plus one bit gives an answer that does not fit in one bit. That is the entire problem, stated in the smallest possible form, and it does not go away at any width: it is why an adder has two outputs rather than one, and why the demonstration on adders later has a Sum pin and a Carry pin instead of just an answer.
Now go to 4 bits and press The largest it goes. Fifteen plus fifteen is thirty, which needs five bits, and the panel says so. The extra bit is not a special case bolted on the end. It is an ordinary carry, arriving in a column that does not exist.
Step 2: Watch a carry travel
Section titled “Step 2: Watch a carry travel”Still at four bits, press No carries, which is 5 + 10, then press Do it column by column and step through it.
Every column is independent. Each one has both its bits from the start and none of them is waiting for anything.
Now press Ripple all the way, which is 7 + 1, and step through that. Read the commentary as each column completes: the rightmost produces a carry, which the next column needs before it can say anything, which produces another carry, and so on all the way to the left.
On paper this costs you nothing but patience. In a circuit it costs time, and the demonstration on adders is largely about how much. It is worth noticing here, while the arithmetic is simple enough that the waiting is the only thing to look at.
Step 3: Try the obvious way to write a negative number
Section titled “Step 3: Try the obvious way to write a negative number”Open A bit for the sign. The scheme is exactly what it sounds like: the top bit says which way, the other three say how much, so 0101 is +5 and 1101 is −5.
Press 5 + -5, which should give zero.
It gives +2. Look at the columns and you can see why, and it is worth being precise about the reason, because the adder has done nothing wrong. It added the sign column exactly as it added every other column, carried into it and out of it as usual, and produced a perfectly correct four-bit sum. The bits were fine. The meaning attached to the top bit was not something the arithmetic could know about.
Now press 2 + 3 and watch it work. That is not a reprieve, it is the diagnosis: both numbers are positive, so both sign bits are 0, nothing is carried into the sign column, and the magnitudes simply add.
Step 4: Read the two panels underneath
Section titled “Step 4: Read the two panels underneath”The table of all sixteen patterns has 0000 and 1000 highlighted, and they are +0 and −0. There is no such number as negative zero, so one of the sixteen patterns has been wasted. The waste is the smaller problem. The larger one is that a circuit asked whether two values are equal now has to know that these two patterns are equal despite differing in a bit, so even a test for zero stops being a matter of looking at the bits.
Then read the counting panel, which is the honest verdict. Every pair whose answer is representable was tried, and 58 out of 169 come out right. That sounds survivable until you look at what the 58 are:
- 36 have both numbers non-negative, so the sign bit is never used
- 14 add zero to something, so nothing is really being added
- 8 work by coincidence, and every one of them involves −4
The coincidences are the best part. A magnitude of 4 is exactly half of 8, so adding it pushes a carry out of the three-bit magnitude field and into the sign column, where it flips the sign to the very value that was wanted. Nothing reasoned about signs. A carry escaped from one field into another and happened to land correctly.
So the scheme works when you are not using the feature it exists to provide, when you are adding nothing, or by accident.
Step 5: Change one weight
Section titled “Step 5: Change one weight”Open Two’s complement and look at the strip at the top.
The columns are worth −8, 4, 2 and 1. That is the only change. Every other column is exactly what it was in the first demonstration of the module, and a number is still the sum of the weights standing under its 1s. The top bit is no longer a label announcing that a number is negative, it is an ordinary column that happens to count downwards, and because it is an ordinary column, ordinary addition works on it.
Click the bits and watch the value. Then check the pattern table: sixteen patterns, sixteen different numbers, one zero. Read the right-hand column upwards from 1111 and it counts −1, −2, −3, which is worth noticing, because the negative numbers are not stored backwards or in any special order. They simply carry on counting down past zero and wrap round to the top of the field.
Now use the addition panel. Try a few pairs, including ones with a negative in them, and note that the verdict is always correct. Nothing on this tab knows anything about signs. The columns were added from the right, carries went where carries go, and the answer came out right.
That is the whole claim for two’s complement, and it is a claim about hardware rather than about notation: the four-bit adder built out of gates later in this module adds signed numbers correctly without a single gate being added to it, because there is nothing to add.
Step 6: Find the number with no opposite
Section titled “Step 6: Find the number with no opposite”Still on the same tab, set the negation stepper to 5 and press Step through it. Invert every bit to get 1010, add one to get 1011, and that is −5.
Now set it to −8.
Inverting and adding one gives −8 back again. That is not a fault in the procedure, it is the procedure telling the truth: +8 needs one more bit than a four-bit field has, so there is no pattern for it. There are sixteen patterns, one of them is zero, and the remaining fifteen cannot be split evenly between positives and negatives. The odd one out is the most negative value, which is why the range runs from −8 to +7 rather than symmetrically.
This is not a curiosity. Taking the absolute value of the most negative integer is a well-known source of bugs in real software, and it has never been fixed because there is nothing to fix.
Step 7: Throw away the subtractor
Section titled “Step 7: Throw away the subtractor”Open Subtraction is addition and press 7 − 5, then Step through it.
Watch the three stages. Five is 0101, inverting gives 1010, adding one gives 1011, which is −5. Then add 0111 and 1011 in the ordinary way and the answer bits read 0010, which is +2.
A carry came out of the top column and was discarded, and that always looks like cheating the first time. It is not. A field of n bits counts in a circle of 2ⁿ values, adding walks you round that circle, and the carry out is simply the moment you pass the starting point. It records that a lap was completed and nothing else.
Notice too that the carry is not an error signal. Press 2 − 6, which gives −4 correctly and produces no carry out at all. Whether a carry appears depends on which two numbers you picked, not on whether the answer is right.
Then switch to six bits and press −25 + 18, which is the larger example from the reading. It gives 111001, which is −7.
The point of all this is a saving in hardware rather than in effort. An adder that can also subtract needs one inverter per bit and one spare input: feed a control line into every inverter and into the carry in at the bottom of the chain, and with it at 0 you get A + B, while with it at 1 every bit of B is inverted and a 1 arrives at the bottom, which is inverting and adding one. One wire turns an adder into a subtractor. That is a remarkable return on a change of notation, and it is why two’s complement is not merely a tidy idea but the one that everybody uses.
Check your understanding
Section titled “Check your understanding”Why does a one-bit adder need two output bits?
Under sign and magnitude, adding +5 and −5 as ordinary binary gives 0010, which reads as +2. What has gone wrong?
Match each idea to what it actually does
A four-bit two's complement subtraction produces a carry out of the top column, which is discarded. What does that carry tell you?
Why can −8 not be negated in a four-bit two's complement field?
Wrap-up
Section titled “Wrap-up”Five things to carry forward.
- Binary addition is one rule. A column totals 0, 1, 2 or 3; write its bottom bit and carry its top bit. Everything else is bookkeeping.
- Two bits will not add into one bit, so an adder always produces one more bit than it consumes. This is true at one bit wide and at sixty-four.
- A sign bit that is only a label breaks arithmetic. It fails on 111 of 169 pairs, and most of the successes are cases where it was not being used.
- A sign bit with a negative weight fixes it completely, and costs nothing in hardware. The same row of adder cells works on signed and unsigned numbers without modification, because there is nothing to modify.
- Subtraction is addition. Negate the second operand and add, which needs one inverter per bit and one control wire, and no subtractor anywhere.
Everything here has been kept carefully inside the range. The operands on the last two tabs are fenced in, and that fence is hiding something real: a fixed-width field holds only so many values, and asking it for one it does not have produces an answer that is not merely approximate but wrong, and wrong without any complaint from the hardware.
That is overflow, and it needs its own demonstration. It comes next, along with the vocabulary for how big these fields are in the first place: the bit, the nibble, the byte and the word.
© 2026 Derek Molloy, Dublin City University. All rights reserved.