2
$\begingroup$

Reading the Appendix A (Binary numbers) of Structured Computer organization by Tanenbaum I've found this exercise:

Signed decimal numbers consisting of $n$ digits can be represented in $n + 1$ digits without a sign. Positive numbers have $0$ as the leftmost digit. Negative numbers are formed by subtracting each digit from $9$. Thus the negative of $014725$ is $985274$. Such numbers are called nine’s complement numbers and are analogous to one’s complement binary numbers. Express the following as three-digit nine's complement numbers: $6$. $-2$, $100$, $-14$, [etc].

Ok, it all works fine with $6$ for instance: using the given rule it is $006 \mapsto 993$. That makes sense: as Tanenbaum says this system for negative-value representation is similar to one's complement: it has two different zero representation ($000$ and $999$) and it has negative possible value as much as the positive ones.

What I don't understand is how can $100$ fit in this scenario. To me, with 3 digits I ca only represent value in range $[-900, 099]$; moreover $100$ is not considered a positive number --it shoudl have a $0$ as leftmost digit.

Is there an error in Tanenbaum-exercise?, if not, where I'm wrong?

$\endgroup$

1 Answer 1

1
$\begingroup$

Nine's complement representation involves a choice of the exact range of positive and negative numbers. It is natural to let the sign depend on the MSD (most significant digit). It is even more natural to declare that numbers starting with $0,1,2,3,4$ are positive, those starting with $5,6,7,8,9$ are negative. The range of three-digit numbers is then $-500$ to $499$ rather than $-900$ to $99$, and $100$ becomes representable. I suspect that this interpretation is what Tanenbaum intended.

$\endgroup$
2
  • 1
    $\begingroup$ Uhm ...Tanenbaum says that positive numbers have $0$ as the leftmost digit, not other value; sound enough clear about that. Though, you're saying 9's complement represent numbers as ..., $997 \mapsto -3$, $998 \mapsto -2$, $999 \mapsto -1$, $0 \mapsto 000$, $1 \mapsto 001$, ... Then $+100$ is represented as $100$ while $-100$ is $899$, right? Then where are the analogies with 1's complement for binary numbers? $\endgroup$ Oct 6, 2013 at 11:05
  • 1
    $\begingroup$ Tanenbaum's book is not infallible. It's not the bible. Either the description or the exercise is wrong, take your pick. The most important thing is to understand the concept of 9's complement, as well as the choice involved regarding the range (which numbers are positive and which negative). It is much less important to understand Tanenbaum's conception of 9's complement, especially given that no one actually uses 9's complement. The exact definition is only important if it's an official definition of a standard data format, which is not the case here. $\endgroup$ Oct 6, 2013 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.