For representing +ve and -ve numbers.
The most significant bit (leftmost) bit:
0 => 0 or positive
1 => negative
e.g. 01110000 => +ve
e.g. 11110000 => -ve
If the left most bit = 0,
01110000 = 2^6+2^5+2^4 = 64+32+16 = 112
If the left most bit = 1, invert every remaining bit and add 1.
11110000 => 0001111 + 1 => 0010000 => -16
Reference:
Two's complement (Wikipedia)
沒有留言:
張貼留言