wpe41.gif (23084 bytes)CIS3355: Business Data Structures
Fall, 2008
 

Which is better: One's or two's complement?

We already mentioned that both procedures work equally as well, but are somewhat different in how they function.

We already saw that one of the reasons we use two's complement: To eliminate the -0:

To illustrate some of the differences between one's and two's complement, we need to add some numbers together. Let's first add the values +56 and - 43 (The answer of course, should be 13). We already know the binary value of 56 (and -56; above). To find the value value of -43: 

Now, adding +56 and - 43:

Which evaluates to:

23 + 22 = 8 + 4 = 12

That's obviously wrong !!!

In one's compliment, if the result is a non-negative value, we need to add '1' to get the correct answer:

Which evaluates to: 23 + 22 = 8 + 4 = 13

Why !!!

Basically, as we saw, binary has two zeros (0):

In order to eliminate one of them, we have to add '1'.

Now, let's add +56 and - 43 using 2's complement 43:

Which evaluates to: 23 + 22 = 8 + 4 = 13

So two's complement IS better !!!

We'll see. Now let's add 43 and -56 (which of course is -13). First let's add using a one's complemented 56:

As we know, whenever a value is negative, we again need to complement in order to make sense of the result:

Which evaluates to: - (23 + 22 + 20) = - (8 + 4 + 1) = -13 (The correct answer).

Now let's add the numbers using a 2's complemented 56:

Again, whenever a value is negative, we again need to complement in order to make sense of the result:

Which evaluates to: - (23 + 22 ) = - (8 + 4 ) = -12

Wait !! That's wrong !!!

Don't forget, when we converted 56 to -56 in two's complement, we added '1' to the result:

So now we have to subtract 1 to make it right ???

Sort of. We can actually get the correct answer by adding '1 after we complement:

Which evaluates to: - (23 + 22 + 20) = - (8 + 4 + 1) = -13 (The correct answer).

So, which is better: One's or two's complement?

As we noted, neither is better, the just use different ways of complementing. Essentially the differences are:

  1. If adding a one's complemented number, if the result is negative, analyze the result.

  2. If adding a one's complemented number, if the result is non-negative, add '1' and then analyze the result.

  3. If adding a two's complemented number, if the result is non-negative, analyze the result.

  4. If adding a two's complemented number, if the result is negative, add '1' and then analyze the result.

In sum respects, the procedures are opposites.

Some good references to help you better understand complementing include:

One's Complement
Two's complement from Free on-line Dictionary of Computing
Data Representation and Integer Arithmetic

Some questions you should be able to answer:

  1. Which of the following statements are true:

a.  With two's complement we add '1' after we complement
b.  With two's complement we add '1' before we complement
c.  With one's complement we don't add '1' before we complement

d.  A and B above
e.  A and C above

Answer: E

  1. Which of the following statements are true:

a.  If adding a one's complemented number, if the result is non-negative, analyze the result.
b. 
If adding a one's complemented number, if the result is non-negative, add '1' and then analyze the result.
c. 
If adding a two's complemented number, if the result is negative, analyze the result.
d. 
If adding a two's complemented number, if the result is non-negative, add '1' and then analyze the result.
e. 
None of the above

Answer: B

  1. Add the values +52 and -37 using BOTH 1's complement and 2's complement.

  1. Add the values +52 and -37 using BOTH 1's complement and 2's complement.

This page was last updated on 05/30/05