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}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)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:
- replace each digit \( d \) of the number by \( 9 - d \) and
- 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.