Search code examples
twos-complementones-complement

Why are the bits inverted in one's complement?


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.


Solution

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