二进制减法与2的补 [英] Binary Subtraction with 2's Complement
问题描述
我需要帮助,用2的再presentation并使用5位为每个号码二进制减去:
I need help subtracting with binary using 2's representation and using 5 bits for each number:
1)-9 -7 =?是否有溢出?
1) -9 -7 = ? Is there overflow?
-9 = 01001(2的补= 10111)和-7 = 00111(2的补= 11001)
-9 = 01001 (2's complement = 10111) and -7 = 00111 (2's complement = 11001)
现在我们需要添加,因为我们使用的是2的补
Now we need to add because we're using 2's complement
10111
11001
= 100000但是,这个答案是没有意义的。另外,我假设有溢出,因为有超过500位的答案。
10111 +11001 = 100000 But this answer doesn't make sense. Also, I'm assuming there's overflow because there are more than 5 bits in the answer.
2)6 - 10,相同的处理之前。负二进制数字没有意义对我
2) 6 - 10, same process as before. Negative binary numbers don't make sense to me
推荐答案
1)-9 - 7
-9 - 7 = -9 + -7
-9 - 7 = -9 + -7
9(二进制)= 01001结果
-9(2的补数)= 10111结果
7(二进制)= 00111结果
-7(2的补数)= 11001
9 (binary) = 01001
-9 (2's complement) = 10111
7 (binary) = 00111
-7 (2's complement) = 11001
10111 +
11001 =
110000
这并不适合5位。删除我们得到10000溢出问题,从而为-16(二进制)。
This doesn't fit into 5 bits. Removing the overflow we get 10000, which is -16 (binary).
2)6 - 10
6 - 10 = 6 + -10
6 - 10 = 6 + -10
6(二进制)= 00110结果
10(二进制)= 01010结果
-10(2的补数)= 10110
6 (binary) = 00110
10 (binary) = 01010
-10 (2's complement) = 10110
00110 +
10110 =
11100
这适合5位,为-4(二进制)。
This fits into 5 bits and is -4 (binary).
这篇关于二进制减法与2的补的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!