All positive, non-zero integer numbers are represented in this manner. There are differences in the way zero and negative numbers are represented, depending upon whether a ones complement , twos complement , or sign-magnitude system was implemented.
Negative X is obtained by inverting each bit of X; i.e.,
-X = not(X)
The leading bit of a number is the sign bit. Positive numbers have a zero as the leading bit; negative numbers have a one as the leading bit.
One consequence of this is that there are two values for zero: +0 and -0.
For example, for a four-bit number (remember, the leading -- that is, leftmost -- bit is a sign bit):Binary: | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
Decimal: | +0 | +1 | +2 | +3 | +4 | +5 | +6 | +7 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | -0 |
Negative X is obtained by inverting each bit of X, and then adding one; i.e.,
-X = not(X)+1
The leading bit of a number is the sign bit. Positive numbers have a zero as the leading bit; negative numbers have a one as the leading bit.
There is only one value for zero: all bits are zero (as opposed to the system used for One's Complement).
For example, for a four-bit number (remember, the leading -- that is,
leftmost -- bit is a sign bit):
Binary: | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 |
1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
Decimal: | 0 | +1 | +2 | +3 | +4 | +5 | +6 | +7 | -8 |
-7 | -6 | -5 | -4 | -3 | -2 | -1 |
Binary: | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 |
1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
Decimal: | +0 | +1 | +2 | +3 | +4 | +5 | +6 | +7 | -0 |
-1 | -2 | -3 | -4 | -5 | -6 | -7 |