1
$\begingroup$

I know the range of the $n$ digit numbers in $r$'s complement system is given as

$r^{n-1}-1$ to 0 to $-r^{n-1}$.

So for 3 bit 2's complement, its:

$(2^2-1)$ to $0$ to $-(2^2)$
that is
$3$ to $0$ to $-4$
that is
$(011)_{\text{2's comp}}$ to $(0)_{\text{2's comp}}$ to $(100)_{\text{2's comp}}$

And for 3 digit 8's complement, its

$(8^2-1)$ to $0$ to $-(8^2)$
that is
$63$ to $0$ to $-64$
that is
$(077)_{\text{8's comp}}$ to $(0)_{\text{8's comp}}$ to $(700)_{\text{8's comp}}$

Now I came to know that

the $r$'s complement of the smallest / most $-$ve number in the range will be the same number.

For example, taking 2's complement of most $-$ve / smallest number possible with 3 bit 2's complement system, $(100)_{\text{2's comp}}$ is itself:

1 0 0  
0 1 1 (1's complement)
1 0 0 (add 1 to get 2's complement)

But taking 8's complement of most $-$ve / smallest number possible with 3 digit 8's complement system, $(700)_{\text{8's comp}}$ does not seem to be itself:

7 0 0
0 7 7 (7's complement)
1 0 0 (add 1 to get 8's complement)

So 8's complement of 700 does not seem to be 700 itself but is in fact 100. So what I am missing? Or I am doing it all wrong?

$\endgroup$
0
$\begingroup$

First of all, if you are considering the $n$th digit of the number as being a sign digit, you can think of it as being either 0 or 1, no matter the value of $r$. In other words, it is always a bit (a binary digit), and that's how you would represent it in hardware, should that be the case.

$[1]73_{\text{8's comp}} = -5$

$[1]73_{\text{8's comp}} + [0]06_{\text{8's comp}} = [0]01_{\text{8's comp}}$

The complement of a negative number represented in $r$'s complement will obviously produce the positive version of that same number. The most negative number doesn't have a positive of the same magnitude that fits into the given number of digits (a weakness of this form of representation).

The number is still there, though, only unsigned:

$[1]00_{\text{8's comp}} = -64_{10}$

$100_8 = 64_{10}$

$\endgroup$
-1
$\begingroup$

The smallest 3-digit 8's complement number is not 700, but 400.

Indeed, the assertion at the start of the question is already wrong: as long as $r$ is even, the actual range is from $-\tfrac r2r^{n-1}$ to $\tfrac r2r^{n-1}-1$.

$\endgroup$
  • $\begingroup$ $-\lfloor\frac{r^n}{2}\rfloor$ to $\lfloor\frac{r^n}{2}\rfloor - (1-r\pmod 2)$ should work for all values of $r$. It would also be interesting if you could explain to the OP why do you think the premise is wrong $\endgroup$ – André Souza Lemos Sep 29 '16 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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