Method of Complements - Numeric Complements

Numeric Complements

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 yx, the result will always be greater or equal to 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.

Read more about this topic:  Method Of Complements