开发者

Why are the bits inverted in one's complement? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center fo开发者_StackOverflowr guidance. Closed 11 years ago.

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.


Because that what one's complement is defined to do. See http://en.wikipedia.org/wiki/Signed_number_representations


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜