Advantage of 2's complement over 1's complement?
What is the advantage of 2's complement over 1's complement in negative number representation in binary number system? How does it affect the range of values stored in a certain bit representation of number in binary system?
The primary advantage of two's complement over one's complement is that two's complement only has one value for zero. One's complement has a "positive" zero and a "negative" zero.
Next, to add numbers using one's complement you have to first do binary addition, then add in an end-around carry value.
Two's complement has only one value for zero, and doesn't require carry values.
You also asked how the range of values stored are affected. Consider an eight-bit integer value, the following are your minimum and maximum values:
Notation Min Max
========== ==== ====
Unsigned: 0 255
One's Comp: -127 +127
Two's Comp: -128 +127
References:
- http://en.wikipedia.org/wiki/Signed_number_representations
- http://en.wikipedia.org/wiki/Ones%27_complement
- http://en.wikipedia.org/wiki/Two%27s_complement
The major advantages are:
-
In 1's there is a
-0
(11111111
) and a+0
(00000000
), i.e two value for the same0
. On the other hand, in 2's complement, there is only one value for0
(00000000
). This is because+0 --> 00000000
and
-0 --> 00000000 --> 11111111 + 1 --> 00000000
-
While doing arithmetic operations like addition or subtraction using 1's, we have to add an extra carry bit, i.e
1
to the result to get the correct answer, e.g.:+1(00000001) + -1(11111110) ----------------- = (11111111)
but the correct answer is 0
. In order to get 0
we have to add a carry
bit 1
to the result (11111111 + 1 = 00000000
).
In 2's complement, the result doesn't have to be modified:
+1(00000001)
+
-1(11111111)
-----------------
= 1 00000000
Negative integers : 2's complement makes sense to be used for negative integers. 1's complement is just a computation technique which might be helpful to evaluate 2's complement. The real (defeated) rival of 2's complement was the sign-magnitude representation for negative integers.
No overflow : 1's complement has no special usage for negative integers. 2's complement makes sense because it can be used in natural addition and subtraction arithmetic without any need to change the bits. Providing that no overflow occurs, the sign bit of the result is just the right value. The bit number promotion in this notation is straight forward, for example, to promote an 8-bit signed integer to 16, we could simply repeat the sign bit of integer value in the high byte of it.
Sign magnitude : On the contrary, the sign-magnitude notation is just the way that human uses to represent negative integers. The bit number promotion and addition subtraction arithmetic is a bit mess with this notation.
Advantages of Two’s Complement #1
In Two’s Complement representation, the value zero is uniquely represented by having all bits set to zero:
**
Advantages of Two’s Complement #2
** When you perform an arithmetic operation (for example, addition, subtraction, multiplication, division) on two signed integers in Two’s Complement representation, you can use exactly the same method as if you had two unsigned integers (that is, nonnegative integers with no sign bit) ... EXCEPT , you throw away the high carry (or the high borrow for subtraction)
Advantages of Two’s Complement #3
This property of Two’s Complement representation is so
incredibly handy that virtually every general
purpose computer available today uses Two’s Complement. Why? Because, with Two’s Complement, we don’t need special algorithms (and therefore extra circuitry) for arithmetic operations that involve negative values.
Another major advantage of Two's complement over signed bit representation is 2's complement representation is easy to manipulate in hardware