- To convert from two's complement to decimal:
- Look at leftmost bit to see if it is positive or negative.
- If positive, convert number from binary to decimal
- If negative, determine magnitude by:
- Complement the bits
- Add 1

- Look at leftmost bit to see if it is positive or negative.
- Example:
11111111 00001001 This is a negative number. Complement is 00000000 11110110 Add 1, result is 00000000 11110111 = 247 So original number was -247.

- To convert from decimal to two's complement:
- If number is positive, convert number from decimal to binary
- If number is negative:
- Convert absolute value of number from decimal to binary
- Complement the bits
- Add 1

- If number is positive, convert number from decimal to binary
- Example:
-8 Representation of |-8| is 00000000 00001000 Complement is 11111111 11110111 Add 1, result is 11111111 11111000 (in hex: fff8 - see table p. 218)

Elizabeth Johnson Last modified: Mon Oct 4 09:31:03 EDT 1999