0

I am having difficulty understanding why the following binary subtraction gives the result that it does. I keep getting a different answer. I am trying to compute 0.1-x such that x is 0.00011001100110011001100. The answer should be 0.000000000000000000000001100[1100]...(1100 keeps repeating) When i do it, I keep getting 1100 in the very beginning.

What am I not doing correctly?

4

1 回答 1

0

我认为您的预期答案是错误的。这是我的解决方案。我会将这些位分组为 nybbles,以便它看起来可读。

  0.1000 0000 0000 0000 0000 0000 <- added zero to the rightmost to fill in the nybble
- 0.0001 1001 1001 1001 1001 1000 <- added zero to the rightmost to fill in the nybble
_________________________________

得到 的 2 的补码0.0001 1001 1001 1001 1001 1000

  1.1110 0110 0110 0110 0110 0111 (1's complement)
+ 0.0000 0000 0000 0000 0000 0001
_________________________________
  1.1110 0110 0110 0110 0110 1000 (2's complement)

将 2 的补码添加到0.1.

  0.1000 0000 0000 0000 0000 0000
+ 1.1110 0110 0110 0110 0110 1000
_________________________________
 10.0110 0110 0110 0110 0110 1000

由于溢出是1,请忽略它。它只是表示最终答案是一个正数,因为0.1它大于0.0001 1001 1001 1001 1001 1000。因此,最终的答案是0.011001100110011001101000

于 2014-01-29T11:29:29.423 回答