为什么二进制补码中的位会反转?
当用补码存储负数时,在加上补码 1 之前,为什么除了符号之外的所有位都反转了?我想如果唯一不同的是标志的话那就更简单了。我能想到的唯一原因是它以某种方式使计算机变得更容易。
When storing a negative number with one's complement before you add the 1 for two's complement, why are all the bits other than the sign inverted? I suppose It would just be simpler if the only thing different was the sign. The only reason I can think of is it somehow make it easier for the computer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为一个人的补语被定义为要做的事情。请参阅http://en.wikipedia.org/wiki/Signed_number_representations
Because that what one's complement is defined to do. See http://en.wikipedia.org/wiki/Signed_number_representations
例如,请参阅http://en.wikipedia.org/wiki/One%27s_complement,或者快速谷歌可以给你的其他来源。
基本上,是的,与符号幅度数相比,它使加法和减法更容易实现(尽管 2 的补码使数学更容易)。
See, for example, http://en.wikipedia.org/wiki/One%27s_complement, or other sources a quick google can give you.
Basically, yes, it makes addition and subtraction easier to implement compared to sign magnitude numbers (though 2's complement makes maths even easier).