Convert decimal +49 and +29 to binary, using the signed‐2’s‐complement representation and enough digits to accommodate the numbers. Then perform the binary equivalent of (+29) + (-49), (-29) + (+49), and (-29) + (-49). Convert the answers back to decimal and verify that they are correct.
1.20
Ans: + 49 is converted as 0 110001 in binary
2’s complement of + 49 is 001110 + 1 = 001111
- 49 is written as (- 2’s complement of + 49) = 1 001111
+ 29 is converted as 0 011101 in binary
2’s complement of + 29 is 100010 +1 = 100011
-29 is written as (-2’s complement of + 29) = 1 100011
(a) (+29) + (-49) = 0011101 + 1001111
= 1101100
Here there is no carry, so find its 2’s complement
2’s complement of 101100 is 010011 +1 = 1010100
= - 20.
(b) (-29) + (+49) = 1100011 + 0110001
= 0010100
Here there is a carry so by discarding it, the result is +20
(c) (-29) + (-49) =
Here to increase the number of bits in a representation of an integer in two's complement, add copies of the leftmost bit (the sign bit) to the left until you have the desired number of bits. This is called sign extension.
= 11 100011 + 11 001111
= 10 110010 (left most 1 represents sign and remaining represents magnitude)
Since there is no carry, 2’s complement of 0110010 = 1001101 + 1
= 1001110
So the result is 1 1001110 = - 78.