Denary to Negative Binary Conversion
An 8-bit two's complement number always uses exactly eight bits, and that fixed width limits which denary values it can hold. The range is -128 to +127 inclusive: 256 different bit patterns, one for each value from -128 up to +127.
The leftmost bit decides the sign. Every pattern that starts with 1 is negative, and there are 128 such patterns, so the negative values run from -128 up to -1. The 128 patterns that start with 0 cover zero and the positive values 0 to +127. Zero takes one pattern of its own, which is why you get 127 positive values but 128 negative ones.
| Denary value | Inside the range? | Reason |
|---|---|---|
| -128 | Yes | The smallest value |
| 0 | Yes | Zero is included |
| +127 | Yes | The largest value |
| +128 | No | Overflow: outside the range |
The bottom of the range is -128, so -128 has a valid code. The value +128 is outside the range. Eight bits have 256 codes and all of them are already used, so there is no spare code for +128. Trying to store a value outside -128 to +127 in eight bits is called overflow.
Overflow can happen even when the two values being added are both inside the range. For example, 90 and 90 are both valid, but 90 + 90 = 180, which is outside -128 to +127. In eight bits, 90 is 01011010. Adding it to itself gives the eight-bit result 10110100. Read as a two's complement number, that pattern means -76, not +180. The answer has wrapped round to a different value, so the result is not a valid larger positive answer.
Adding 1 to the largest positive value, +127, does something similar: the carry ripples through every 1 bit, the sign bit turns to 1, and the pattern is read as the smallest negative value instead of a bigger positive one. That too is an overflow.
Edexcel GCSE Computer Science · Denary to Negative Binary Conversion