Signed integers (cont)
Several possible representations for negative values
- signed magnitude ... first bit is sign, rest are magnitude
- ones complement ... form -N by inverting all bits in N
- twos complement ... form -N by inverting N and adding 1
In all representations, +ve numbers have 0 in leftmost bit
Examples: representations of (8-bit) -5 (where 5 is 00000101 )
-
10000101 ... signed magnitude
-
11111010 ... ones complement
-
11111011 ... twos complement
|