Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 461
pranphy Avatar asked Jun 15 '12 15:06

pranphy


People also ask

What is the advantage of 2's complement system?

Explanation: The advantage of 2's complement is that only one arithmetic operation is required for 2's complement's operation and that is only addition. Just by adding a 1 bit to 1's complement, we get 2's complement.

Which one is better between 1's and 2's complements Why?

1's complement arithmetic operations are not easier than 2's complement because of addition of end-around-carry-bit. 2's complement arithmetic operations are much easier than 1's complement because of there is no addition of end-around-carry-bit.

What is the difference between 1's and 2's complement?

The main difference between 1′ s complement and 2′ s complement is that 1′ s complement has two representations of 0 (zero) — 00000000, which is positive zero (+0), and 11111111, which is negative zero (-0); whereas in 2′ s complement, there is only one representation for zero — 00000000 (0) because if we add 1 to ...

What is the disadvantage of 1's complement?

Disadvantages. 1's complement notation is not very simple to understand because it is very much different from the conventional way of representing signed numbers. The other disadvantage is that there are two notations for 0 (0000 and 1111), which is very inconvenient when the computer wants to test for a 0 result.


2 Answers

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
like image 134
JYelton Avatar answered Oct 20 '22 18:10

JYelton


The major advantages are:

  1. In 1's there is a -0 (11111111) and a +0 (00000000), i.e two value for the same 0. On the other hand, in 2's complement, there is only one value for 0 (00000000). This is because

    +0 --> 00000000 

    and

     -0 --> 00000000 --> 11111111 + 1 --> 00000000 
  2. 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 
like image 26
GAURAV SINGH Avatar answered Oct 20 '22 16:10

GAURAV SINGH