For signed integers, the left most bit position determines whether the integer is negative or not. This is called the sign bit.
For the char type the sign bit position is 7.
For the int type the sign bit position is 31.
8 Bits | As unsigned char | As char |
---|---|---|
0000 0000 | 0 | 0 |
0000 0001 | 1 | 1 |
. | . | . |
. | . | . |
. | . | . |
0111 1111 | 127 | 127 |
1000 0000 | 128 | -128 |
1000 0001 | 129 | -127 |
. | . | . |
. | . | . |
. | . | . |
1111 1111 | 255 | -1 |