Integer |
2's Complement |
---|
Signed |
Unsigned |
|
5 |
5 |
0000 0101 |
4 |
4 |
0000 0100 |
3 |
3 |
0000 0011 |
2 |
2 |
0000 0010 |
1 |
1 |
0000 0001 |
0 |
0 |
0000 0000 |
-1 |
255 |
1111 1111 |
-2 |
254 |
1111 1110 |
-3 |
253 |
1111 1101 |
-4 |
252 |
1111 1100 |
-5 |
251 |
1111 1011 |
look at the above example.
The most significant (leftmost) bit indicates the sign of the integer; therefore it is sometimes called the sign bit.
If the sign bit is zero,
then the number is greater than or equal to zero, or positive.
If the sign bit is one,
then the number is less than zero, or negative.