i know unsigned,two's complement, ones' complement and sign magnitude, and the difference between these, but what i'm curious about is:
Signed 2's complement (or sign 2's complement) (s2c) is a modification of the sign-magnitude form in which addition and subtraction work the way that you expect them to. The price we pay is that we can't read a negative number directly.
Two's complement came about when someone realized that 'going negative' by subtracting 1
from 0
and letting the bits rollunder actually made signed arithmetic simpler because no special checks have to be done to check if the number is negative or not. Other solutions give you a discontinuity between -1
and 0
. The only oddity with two's complement is that you get one more negative number in your range than you have positive numbers. But, then, other solutions give you strange things like +0
and -0
.
According to Wikipedia, the name itself comes from mathematics and is based on ways of making subtraction simpler when you have limited number places. The system is actually a "radix complement" and since binary is base two, this becomes "two's complement". And it turns out that "one's complement" is named for the "diminished radix complement", which is the radix minus one. If you look at this for decimal, the meanings behind the names makes more sense.
Method of Complements (Wikipedia)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With