Perform each of the following subtractions using twos complement arithmetic and a word size of 8 bitsShow all working and check your answersa 7 - 3 b 15 - 17 c 28 - 20
(a) To subtract 3 from 7 using two's complement arithmetic with a word size of 8 bits, we first need to represent both numbers in binary form.
7 in binary is 00000111. 3 in binary is 00000011.
To subtract 3 from 7, we can invert the bits of 3 and add 1 to it to get its two's complement representation.
Inverting the bits of 3: 00000011 -> 11111100.
Adding 1 to the inverted bits: 11111100 + 1 = 11111101.
Now, we can perform the subtraction by adding the two's complement representation of 3 to 7.
00000111 (7)
- 11111101 (-3)
00000110 (6)
Therefore, 7 - 3 = 6.
(b) To subtract 17 from 15 using two's complement arithmetic with a word size of 8 bits, we first need to represent both numbers in binary form.
15 in binary is 00001111. 17 in binary is 00010001.
To subtract 17 from 15, we can invert the bits of 17 and add 1 to it to get its two's complement representation.
Inverting the bits of 17: 00010001 -> 11101110.
Adding 1 to the inverted bits: 11101110 + 1 = 11101111.
Now, we can perform the subtraction by adding the two's complement representation of 17 to 15.
00001111 (15)
- 11101111 (-17)
00001110 (14)
Therefore, 15 - 17 = 14.
(c) To subtract 20 from 28 using two's complement arithmetic with a word size of 8 bits, we first need to represent both numbers in binary form.
28 in binary is 00011100. 20 in binary is 00010100.
To subtract 20 from 28, we can invert the bits of 20 and add 1 to it to get its two's complement representation.
Inverting the bits of 20: 00010100 -> 11101100.
Adding 1 to the inverted bits: 11101100 + 1 = 11101101.
Now, we can perform the subtraction by adding the two's complement representation of 20 to 28.
00011100 (28)
- 11101101 (-20)
00101001 (41)
Therefore, 28 - 20 = 41.
原文地址: https://www.cveoy.top/t/topic/i2oK 著作权归作者所有。请勿转载和采集!