Skip to main content
Engineering LibreTexts

14.4: Ten’s Complement of a Number

  • Page ID
    43746
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    To fully understand 2’s complement it is worth to see how it works with decimal numbers. There is no obvious usage for 10’s complement, but here the point we want to show is that a complement is the replacement of addition with subtraction (i.e., adding the complement of A to B is equivalent to subtracting A from B).

    The 10’s complement of a positive decimal integer \( n \) is 10 to the power of \( (k) \), minus \( n \), where \( k \) is the number of digits in the decimal representation of \( n \). \( \mathit{Complement}_{10}(n) = 10^{k} - n \). For example \( \mathit{Complement}_{10}(8) = 10^{1} - 8 \), \( \mathit{Complement}_{10}(1968) = 10^{4} - 1968 = 8032 \). Here \( k = 4 \) since 1968 is composed of 4 digits.

    It can be calculated in the following way:

    1. replace each digit \( d \) of the number by \( 9 - d \) and
    2. add one to the resulting number.

    Examples. The 10's complement of 1968 is \( 9 - 1 \), \( 9 - 9 \), \( 9 - 6 \), \( 9 - 8 + 1 \), i.e., \( 8031 + 1 \) i.e., 8032. Using the rule two we compute \( 9 - 1 \), \( 9 - 9 \), \( 9 - 6 \), \( 10 - 8 \) i.e., 8032. So our 10's complement is 8032. Indeed \( 1968 + 8032 = 10000 = 10^{5} \). Therefore it correctly follows the definition above: 8032 is the result of \( 10000 - 1968 \).

    The 10's complement of 190680 is then \( 9 - 1 \), \( 9 - 9 \), \( 9 - 0 \), \( 9 - 6 \), \( 9 - 8 \), \( 9 - 0 + 1 \) i.e., \( 809319 + 1 \) i.e., 809320. Let's verify: \( 190680 + 809320 = 1000000 \).

    To compute the 10's complement of a number, it is enough to perform \( 9 - d \) for each digit and add one to the result.

    Some books propose another equivalent way of computing the 10's complement: (1) All the zeros at the right-hand end of the number remain as zeros, (2) The rightmost non-zero digit \( d \) of the number is replaced by \( 10 - d \), and (3) Each other digit \( d \) is replaced by \( 9 - d \).

    Computer scientists will probably prefer the first way since it is more regular and adding 1 is cheaper than making more tests.

    Subtraction at work

    The key point of complement techniques is to convert subtractions into additions. Let us check that.

    Examples. Suppose we want to perform the subtraction \( 8 - 3 = 5 \). We will transform such a subtraction into an addition using the 10's complement.

    The 10's complement of 3 is \( 9 - 3 + 1 = 7 \). We add 7 to 8 and get 15. We drop the carry that we obtained from the addition and we obtain 5. In fact, the ideas is that \( 8 - 3 = 8 - (10 - 7) = 8 + 7 - 10 = 15 - 10 = 5 \).

    Now let's compute \( 98 - 60 \). The 10's complement of 60 is \( 9 - 6 \), \( 9 - 0 \) i.e., \( 39 + 1 \) i.e., 40. \( 98 - 60 = 98 + 40 - 100 = 138 - 100 = 38 \). Therefore we could say that \( 98 - 60 = 98 + 40 = (1)38 \) and we drop the carry.

    Now to perform \( -98 + 60 \) we compute the 10's complement of 98, then the sum, then the 10's complement of the sum and negate the result. i.e., \( -98 + 60 \) becomes \( 2 + 60 = 62 \). 62 10's complement is 38. We negate it and therefore \( -98 + 60 = -38 \).

    Another look at it. Replacing a number by its 10's complement is based on \( a - b = a - (10 - c) \) where \( 10 = b + c \). Imagine that we want to perform the following expression \( 190680 - 109237 \) which equals to \( 81443 \). The 10's complement takes advantage of the fact that \( 109237 \) is also \( 999999 - 890762 \) or \( 1000000 - 890763 \) where 890763 is the 10's complement of \( 109237 \).

    109237 = 999999 - 890762
    109237 = 999999 - 890762 (+ 1 - 1)
    109237 = 1000000 - 890762 - 1
    

    Now the first subtraction is expressed as:

    190680 - 109237
    = 190680 - (1000000 - 890762 - 1)
    = 190680 - 1000000 + 890762 + 1
    = 190680 + 890762 + 1 - 1000000
    = 1081443 - 1000000
    = 81443
    

    Before getting into 2's complement we will look at negative number representation.


    This page titled 14.4: Ten’s Complement of a Number is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Alexandre Bergel, Damien Cassou, Stéphane Ducasse, Jannik Laval (Square Bracket Associates) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.