Why is not the minimum value like this:
11111111 11111111 11111111 11111111
Please help me understand this.
Let's use a 3-bit example to keep things simple.
The value 0
represented as a 3-bit binary number is 000
.
If we subtract 1
from 0
, we get -1
. If we subtract 1
from 000
, we get 111
with a borrow that "falls off" because we only have 3 bits.
If we continue to subtract 1, we get:
-1 111
-2 110
-3 101
-4 100
If we start back at 0
and add 1
, we get the positive numbers:
+1 001
+2 010
+3 011
But when we try to add another 1
, we get the representation for -4
instead of +4
.
This is just like what would happen if you tried to wind back the odometer on your car. Once you reached 0, the next number would be 9999999 (or however many digits there are on an odometer), but this can naturally be thought of as a representation of -1. As you wind back even further, the number will move away from all 9's, but it would represent more negative values. We could say that if the leftmost digit is between 0 and 4, then the number is positive, and if it is between 5 and 9, then it is negative. As we continue to wind backwards, we will eventually reach 5000000, which is the most negative value. Winding back once more causes an overflow because we get 4999999, which we consider to be positive (the most positive value). Incidentally, this is called 10's complement, and was used by Charles Babbage to represent negative numbers in his difference engine.