Decimal to Two's Complement Conversion

[Decimal to Two's Complement Conversion] [Two's Complement to Decimal Conversion] [Two's Complement Binary Addition Examples]

These examples show conversion of a decimal number to 8-bit twos
complement. The bit size is always important with twos
complement, since you must be able to tell where the sign bit is.
The steps are simple. First, you convert the magnitude of the number to binary, and pad to the word size (8 bits). If the original number was positive, you are done. Otherwise, you must negate the binary number by inverting the bits and adding 1.

- Convert -72 to an 8-bit, twos complement binary number.
- Convert the magnitude, 72 to binary. The easiest way is to
convert it to hex first. 72÷16 = 4 remainder 8, so
72
_{10}= 48_{16}= 1001000_{2}. - Pad to 8 bits: 01001000
- Negate the number by inverting the bits and adding 1.
0 1 0 0 1 0 0 0 ¬ 1 0 1 1 0 1 1 1 + 1 1 0 1 1 1 0 0 0 _{10}is 10111000 as an eight-bit, two's complement number.

- Convert the magnitude, 72 to binary. The easiest way is to
convert it to hex first. 72÷16 = 4 remainder 8, so
72
- Convert 47 to an 8-bit, twos complement binary number.
This is positive, so all that is needed is to convert to binary and
pad to eight bits. 47÷16 = 2 remainder 15, so
47
_{10}= 2f_{16}= 101111_{2}. So 47 as an 8-bit two's complement number is just 00101111. - Convert -109 to an 8-bit, twos complement number. Again, the
magnitude: 109÷16 = 6 remainder 13, so
109
_{10}= 6d_{16}= 1101101_{2}.0 1 1 0 1 1 0 1 ¬ 1 0 0 1 0 0 1 0 + 1 1 0 0 1 0 0 1 1 - Convert -67 to an 8-bit, twos complement number.
67÷16 = 4 remainder 3, so
67
_{10}= 43_{16}= 1000011_{2}.0 1 0 0 0 0 1 1 ¬ 1 0 1 1 1 1 0 0 + 1 1 0 1 1 1 1 0 1 - Convert 81 to an 8-bit, twos complement number.
Since this is positive, it's just a matter of
converting to binary and padding to 8 bits.
81÷16 = 5 remainder 1, so
81
_{10}= 51_{16}= 1010001_{2}, giving 01010001.