Conversion from the Decimal system to the 2’s Complement system


The conversion of a decimal number to the 2’s complement system is similar to the decimal - signed-magnitude conversion. If the number is positive, it is represented by its ordinary binary representation, using enough bits that the MSB (the sign bit) is 0. The two's complement operation is the negation operation. Firstly, the number is converted into the binary form, then all of the bits are inverted, by the bitwise NOT operation and the value of 1 is added to them. In the case of a negative number MSB is equal to 1.
Example 1:
12
12 | 2 0
6 | 2 0
3 | 2 1
1 | 2 1

12 = 1100 in NBC
12 = 00001100 in 2'C

Example 2:
-80
80 | 2 0
40 | 2 0
20 | 2 0
10 | 2 0
5 | 2 1
2 | 2 0
1 | 2 1

80 = 1010000 in NBC
80 = 01010000 in 2'C
Flipping the bits and adding 1
10101111 + 1 = 10110000
-80 = 10110000 in 2'C