deepak said:
What machine is going to gain by changing it to 2's complement from
1's complement?
[...]
I'm having trouble understanding your question, but I'll try to answer
it anyway.
Representing unsigned integers is straightforward: each bit represents
a power of two. (There are complications, but we'll ignore them for
now). Representing signed integers is a bit more tricky.
There are three major ways to represent signed integers:
sign-and-magnitude simply reserves a bit to indicate the sign; this
bit is set to 0 for positive numbers, 1 for negative numbers. To
negate a number, just flip the sign bit.
In ones' complement, you negate a number by flipping *all* the bits.
In two's complement, you negate a number by flipping all the bits and
then adding 1.
It turns out that two's complement has considerable advantages over
the other representations. For one thing, it doesn't have two
different representations for zero; if you negate 0, you just get 0
again. The other representations both have distinct representations
for +0 and -0, which means you have to decide how to deal with them.
(Are +0 and -0 equal? If so, you can't compare two numbers just by
comparing all the bits.) Also, if you ignore overflow/wraparound,
many signed and unsigned operations are identical.
For this and other reasons, almost all machines these days use two's
complement for signed integers; the other representations aren't quite
dead, but they're rare.