# Method of Complements

From wikipedia:  https://en.wikipedia.org/wiki/Method_of_complements

In mathematics and computing, the method of complements is a technique used to subtract one number from another using only addition of positive numbers. This method was commonly used in mechanical calculators and is still used in modern computers.

The nines’ complement of a number is formed by replacing each digit with nine minus that digit. To subtract a decimal number y (the subtrahend) from another number x (the minuend) two methods may be used:

## Decimal example

Digit Nines’
complement
0 9
1 8
2 7
3 6
4 5
5 4
6 3
7 2
8 1
9 0

The nines’ complement of a decimal digit 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, see table. To form the nines’ complement of a larger number, each digit is replaced by its nines’ complement.

Consider the following subtraction problem:

```  873  (x, the minuend)
- 218  (y, the subtrahend)
```

### First method

We compute the nines’ complement of the minuend, 873. Add that to the subtrahend 218, then calculate the nines’ complement of the result.

```  126  (nines' complement of x)
+ 218  (y, the subtrahend)
```

=

```  344
```

Now calculate the nines’ complement of the result

```  344 (result)
655 (nine's complement of result, the correct answer)
```