One practical application of the method of complements is for performing subtraction in a computer microprocessor which uses the binary numeral system. Binary computers typically employ the two's complement for the operation of subtraction.

In the decimal numbering system, the method of complements can be carried out using *nine's complement* or *ten's complement*.

Table of contents |

2 Ten's complement 3 Comments |

To subtract a number *y* (the subtrahend) from another number *x* (the minuend), nine's complement may be used. In this method, *y* is *complemented* by determining the complement of each digit. The complement of a decimal digit in the nine's complement system is the number that must be added to it to produce 9. The complement of 3 is 6, the complement of 7 is 2, and so on. Given a subtraction problem:

873 (x) - 218 (y)The nine's complement of

Next, the complement of *y* is *added* to *x*:

873 (x) + 781 (complement of y) = 1654The first "1" digit is then dropped, giving 654. Finally, 1 is added to the result, giving 655. It can easily be verified that 873 - 218 = 655.

This technique works differently if *x* < *y*. In that case, there will not be a "1" digit to cross out at the end, and nor is a "1" added to the result. For example:

185 (x) - 329 (y)Complementing

185 (x) + 670 (y) = 855The result of 855 is then complemented, giving 144. Since

873 (x) - 218 (y)The complement of

873 (x) + 782 (complement of y) = 1655Dropping the initial "1" gives 655. Since ten's complement was used, there is no need to add 1 to the result.

For cases where *x* <= *y*, the second approach must be used. Note that with ten's complement, if *x* = *y*, this approach must be used also. Using the same example as before:

185 (x) - 329 (y)Complementing

185 (x) + 671 (y) = 856Finally, complementing 856 with ten's complement gives the result 144, or -144 once the negative sign is added.

The necessity of erasing the initial "1" in the result is convenient, particularly considering that computer microprocessors typically have a limited, fixed number of digits with which to perform arithmetic. In a microprocessor that can only contain 8 bits, for example, the leftmost "1" in the examples above is equivalent to the ninth bit, which is lost during calculation. Since subtraction may be a complex operation involving multiple steps for a microprocessor, the method of complements is extremely useful for performing subtractions using only addition. For details, see two's complement.