-
Positive integers are represented in a straightfoward positional scheme.
-
Corresponding negative integer binary representations are calculated by the following steps:
-
Invert each bit of the positive number.
-
Add 1.
-
If there is a carry over from the highest bit, ignore it.
-
The same steps are used to go from negative back to positive number.
|
-
8 bit two's complement:
Binary value |
Two's complement interpretation |
Unsigned interpretation |
00000000 |
0 |
0 |
00000001 |
1 |
1 |
... |
... |
... |
01111110 |
126 |
126 |
01111111 |
127 |
127 |
10000000 |
-128 |
128 |
10000001 |
-127 |
129 |
10000010 |
-126 |
130 |
... |
... |
... |
11111110 |
-2 |
254 |
11111111 |
-1 |
255 |
|