1

I have been trying to figure out whether two numbers wud get the same 9's complement value.. I found a general equation for (r-1)'s complement from a text as : (r^n) - (r^-m) - N where r = radix or Base; n= no of digits in the integer part; m= no. of digits in the fractional part and N=Given value..

But when I apply this eqn to find 9's complement of two numbers: 0.473 and 9.473 then I get the same result for both i.e. 0.526 i.e. (10^0) - (10^-3) - 0.473 = 0.526; and (10^1) - (10^-3) - 9.473 = 0.526

Is there another solution to this since these two numbers cannot yield the same result (it shud be wrong)..??

Abraham Jaison
  • 469
  • 1
  • 6
  • 14

1 Answers1

0

The n and m values in your formula are not "no of digits in the integer part" and "no. of digits in the fractional part" in a particular N value. These n and m are some numbers that should be chosen once for all your work with complement numbers and not changed, and which set limits on the numbers you can work with: after you choose some n and m, you can work only with numbers with at most n digits in integer part and at most m digits in fractional part.

So for your example if you choose n=0, then you can not process 9.473. To be able to process both 0.473 and 9.473, you should choose, for example, n=1 and m=3 and get 0.526 and 9.526 as results.

Petr
  • 9,812
  • 1
  • 28
  • 52