Hint: memorize that the all ones bit pattern represents the decimal value -1 in any number of bits (2's complement).
How this representation may be calculated:
Start with the 8-bit representation for +18: 00010010
Find the additive inverse (also called "taking the two's complement").
00010010
11101101 (the bitwise complement)
+ 1
----------
11101110 (the additive inverse)
This represents the decimal value 127.
This represents the decimal value -128.
The operation is called sign extension.
| Copyright © Karen Miller, 2007 |