Add the following decimal numbers in 2's complement
i) -12 and -18.
11) -14 from +12.
i) To add -12 and -18 in 2's complement, first convert the decimal numbers to their binary representation:
-12 = (0)1100 in 2's complement
-18 = (1)0002 in 2's complement
Now add the two binary numbers:
01100 (12 in binary representation)
+ 10002 (-18 in 2's complement)
_________________________
1 11110
The result in binary is 11110. Since the most significant bit is 1, indicating that it is a negative number, we convert it back to its decimal representation:
11110 in 2's complement = -30 in decimal
Therefore, -12 + -18 = -30
ii) To subtract -14 from +12, first convert the decimal numbers to their binary representation:
+12 = 01100
-14 = (1)0010 in 2's complement
Now subtract the binary numbers:
01100 (12 in binary representation)
- 10010 (-14 in 2's complement)
________________________
11010
The result in binary is 11010. Since the most significant bit is 1, indicating that it is a negative number in 2's complement, we convert it back to its decimal representation.
11010 in 2's complement = -10 in decimal
Therefore, +12 - (-14) = -10
To add decimal numbers in 2's complement, follow these steps:
i) -12 and -18:
1. Convert each number to binary using 2's complement representation.
-12 in binary: 11100
-18 in binary: 10010
2. Add the binary numbers together, including any carry-over.
11100 +
10010
_______
101010
3. The result in binary is 101010, which represents -30 in decimal.
11) Convert +12 to 2's complement:
1. Find the binary representation of 12, which is 1100.
2. Take the 1's complement of 1100 by flipping all the bits.
1100 -> 0011
3. Add 1 to the 1's complement to find the 2's complement.
0011 + 1 = 0100
4. The 2's complement of +12 is 0100.
Now subtract the 2's complement of 14 (which is 14):
1. Find the binary representation of 14, which is 1110.
2. Add the 2's complement of 14 to +12 (0100):
0100 +
1110
_______
10010
3. The result in binary is 10010, which represents -6 in decimal.
Therefore, the answer to -14 from +12 is -6.