While the complements method involves one more step than borrowing, it reuses rote knowledge already learnt for addition whereas to do borrowing efficiently requires learning another set of number pairings.
The radix complement of an n digit number y in radix b is, by definition, . Adding this to x results in the value or . Assuming y ≤ x, the result will always be greater than and dropping the initial '1' is the same as subtracting , making the result or just , the desired result.
The radix complement is most easily obtained by adding 1 to the diminished radix complement, which is . Since is the digit repeated n times (because , see also binomial numbers), the diminished radix complement of a number is found by complementing each digit with respect to (that is, subtracting each digit in y from ). Adding 1 to obtain the radix complement can be done separately, but is most often combined with the addition of x and the complement of y.
In the decimal numbering system, the radix complement is called the ten's complement and the diminished radix complement the nines' complement. In binary, the radix complement is called the two's complement and the diminished radix complement the ones' complement. The naming of complements in other bases is similar. Some people, notably Donald Knuth, recommend using the placement of the apostrophe to distinguish between the radix complement and the diminished radix complement. In this usage, the four's complement refers to the radix complement of a number in base four while fours' complement is the diminished radix complement of a number in base 5. However, the distinction is not important when the radix is apparent (nearly always), and the subtle difference in apostrophe placement is not common practice. Most writers use one's and nine's complement, and many style manuals leave out the apostrophe, recommending ones and nines complement.
To subtract a decimal number y from another number x using the method of complements, the ten's complement of y (nines' complement plus 1) is added to x. Typically, the nines' complement of y is first obtained by determining the complement of each digit. The complement of a decimal digit in the nines' 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:
- 218 (y)
The nines' complement of y (218) is 781. In this case, because y is three digits long, this is the same as subtracting y from 999. (The number of 9's is equal to the number of digits of y.)
Next, the sum of x, the nines' complement of y, and 1 is taken:
+ 781 (complement of y)
+ 1 (to get the ten's complement of y)
The first "1" digit is then dropped, giving 655, the correct answer.
If the subtrahend has fewer digits than the minuend, leading zeros must be added which will become leading nines when the nines' complement is taken. For example:
- 391 (y)
becomes the sum:
+ 99608 (nines' complement of y)
+ 1 (to get the ten's complement)
Dropping the "1" gives the answer: 47641
The method of complements is especially useful in binary (radix 2) since the ones' complement is very easily obtained by inverting each bit (changing '0' to '1' and vice versa). And adding 1 to get the two's complement can be done by simulating a carry into the least significant bit. For example:
01100100 (x, equals decimal 100)
- 00010110 (y, equals decimal 22)
becomes the sum:
+ 11101001 (ones' complement of y)
+ 1 (to get the two's complement)
Dropping the initial "1" gives the answer: 01001110 (equals decimal 78)
The method of complements normally assumes that the operands are positive and that y ≤ x, logical constraints given that adding and subtracting arbitrary integers is normally done by comparing signs, adding the two or subtracting the smaller from the larger, and giving the result the correct sign.
Let's see what happens if x < y. In that case, there will not be a "1" digit to cross out after the addition since will be less than . For example (in decimal):
- 329 (y)
Complementing y and adding gives:
+ 670 (nines' complement of y)
This is obviously the wrong answer; the expected answer is -144. But it isn't as far off as it seems; 856 happens to be the ten's complement of 144. This issue can be addressed in three ways:
The method of complements was used in many mechanical calculators as an alternative to running the gears backwards. For example:
Use of the method of complements is ubiquitous in digital computers, regardless of the representation used for signed numbers. However, the circuitry required depends on the representation:
To teach subtraction by the method of complements, first the class must learn the ten's complement and the nine's complement of each digit. To work a problem such as 1000 - 280, you write the nine's complement of each digit in the subtrahend except the rightmost non-zero digit, for which you write the ten's complement. The answer is thus 720. If you are subtracting a number from 1000 that has fewer than three digits, you add lead 0's to fill the number out to three digits. You can also use the method of complements for a problem such as 83 - 24. Think: "the ten's complement of 4 is 6". Add 6 to both 83 and 24 to get 89 - 30 = 59". These are just two of the many mental math "tricks" that involve the method of complements.
The definition of complements used in computer science has been extended, so that in elementary education we say that the n's complement of k is n - k. Thus, for example, in working with fractions, we can say that the 1's complement of 2/5 is 3/5.
Researchers Submit Patent Application, "Semiconductor Memory Device and Method of Operating the Same", for Approval
Apr 17, 2013; By a News Reporter-Staff News Editor at Electronics Newsweekly -- From Washington, D.C., VerticalNews journalists report that a...
Agency Reviews Patent Application Approval Request for "Method of Operating Memory Controller, Memory Controller, Memory Device and Memory System"
Nov 08, 2012; By a News Reporter-Staff News Editor at Politics & Government Week -- A patent application by the inventors Cho, Kyoung-Lae...