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

What is complementing?

We are talking about complementing, not complimenting!

Basically, the idea of complementing arose from a very simple observation based on the question:

Which mathematical operation is simpler:

  1. 4,345 + 3,789, or

  2. 4,345 - 3,789 ??

Almost everyone would indicate that addition is easier than subtraction. Blaise Pascal (1623  - 1662), who invented the world's first mechanical adding machine, the Pascaline (right), found that in order for his machine to perform subtraction, he had to physically change the 'wheels' on his machine. However, he found a technique which would allow him to perform subtraction without actually making any physical changes.

How ???

Let's first take a look at complementing in decimal (base 10). Here are some complementary values:

Value

Complement

Why

7 3 Because 7 + 3 = 10 and 10 - 7 = 3
29 71 Because 29 + 71 = 100 and 100 - 71 = 29
732 268 Because 732 + 268 = 1000 and 1000 - 732 = 268

So what ???

We can either subtract a number from another number, or add the complement of that number. For example:

What does this have to do with binary ???

In binary, complement complements are very easy to determine. For example:
 

Value

Complement

Why

1 0 Because 1 + 0 = 1 and 1 - 0 = 0
0 1 Because 0 + 1 = 1 and 0 - 1 = 1

This is known as One's Complement. Basically, it means that whenever we find a '0', we change it to a '1'; Whenever we find a '1', we change it to a '0'.

Let's go back to our previous example.

Now If we add +56 and -56, we get:

But that is not the value 0 (zero) !!!

Actually, it is. First, look at the sign bit (the left-most bit). Notice that is '1' (meaning the value stored is negative). Because negative values are stored as complemented values (or in the case of binary, the opposite of the number), to make sense of the value, we once again need to complement (change the '0's to '1' and the '1's to '0'):

And the final value turns out to be -0 (negative zero).

Negative zero !!! How is that possible ???

Actually, zero is neither negative nor non-negative. We could have either a +0 or a -0 (or both).

Is there any way to get rid of negative zeros ???

Yes. We need to slightly modify the process and use two's complement. That, however, will be our next tutorial.

Some good references to help you better understand complementing include:

One's Complement (1)
One's Complement (2)
One's Complement (3)

Some questions you should be able to answer:

  1. Complementing involves:

a.  finding a number which can be added instead of subtracted
b.  finding the opposite of a number
c.  finding two numbers which when added together equal 10
d.  finding two numbers which when subtracted from each other equal 0
e.  finding two numbers which when divided by each other equal 1

  1. The 10's complement of 181 is:

    a.  81             d.  19
    b.  -181          e.  819
    c.  -81
     

  2. The 2's complement of '1' is:

    a.  1            d.  8
    b.  0            e.  ½
    c.  2
     

  3. What is the 10's complement of 78?

  4. What is the 8's complement of 3?

  5. What is the one's complement of the binary number 0011011101011101?

Answers:

  1. A

  2. D

  3. B

  4. 12 because 78 + 12 = 100 and 100 - 78 = 12

  5. 5 because 38 + 5 = 108 and 108 - 38 = 5

  6. 1100100010100010

    This page was last updated on 05/30/05