Electronic – When adding binary numbers, how do you just ignore the overflow

binarydigital-logic

So lets say I used 2's complement to put -17 in binary and then I added it to +27, e.g.:

  +27    0001 1011b
+ -17    1110 1111b
-------------------
  +10    0000 1010b

This calculation here should have an overflow of 1. Where did this overflow of 1 go? How can you possibly just disregard it when it would completely change the whole calculation?

When you add 2's complement numbers, does it just always mean you have to work in a predefined number of bits, and if so, why?

Also, does 2's complement have -0 value and a +0 or only one 0 value?

Best Answer

There are many ways to explain it. Here is one.

Eight-bit signed binary can represent integers as low as -128DECIMAL and as high as +127DECIMAL. So, why can it not represent the next greater integer, +128DECIMAL?

Answer: it could represent +128DECIMAL. The trouble is, the representation would be the same as that of -128DECIMAL. See:

DECIMAL   BINARY
-128      1000 0000
-127      1000 0001
-126      1000 0010
...
+126      0111 1110
+127      0111 1111
+128      1000 0000
+129      1000 0001
+130      1000 0010
...

Observe:

  • +128DECIMAL is indistinguishable from -128DECIMAL;
  • +129DECIMAL is indistinguishable from -127DECIMAL;
  • +130DECIMAL is indistinguishable from -126DECIMAL;
  • and so on.

By keeping the carry bit (it's actually not an overflow bit; overflow is something else), you would be affirming the false representation, wouldn't you? Try it. You'll see.

You don't want that carry bit.

NOTES ON OVERFLOW

If you wish to know what overflow is, it's what happens when you try (for example) to add 96DECIMAL + 64DECIMAL. The result comes out as -32DECIMAL, which is wrong because the addition register has overflowed.

Note that the example, incidentally, has no carry.