Search code examples
binaryradixcomplement

Find the complement using base 9


I have this simple problem which for some reason I have trouble with I'll be glad to get help.

I have these two numbers in base 10 :

5250, 321.

I change the basis from 10 to 9 then I get :

5250 --> 7173

321 ---> 386

I use the method of r complement with base 9:

First of all I'll find the the complement of 0386 in base 9 which is 6561-386=6175.

Therefore :

7173+6175=14358 (in base 9)

since its a complement to 9, we receive 4358 in base 9

Which is incorrect.

Any ideas why my method is incorrect?

Any help will be appreciated.


Solution

  • you are mixing bases. 6561 is base 10 for 10000 in base 9.

    You need to calculate 100000 - 386 in base 9 to get the complement. This results in 88503. So 88503 is the 10's complement of 386 in base 9. Note the extra digit, otherwise 7173 will be a negative number in this representation.

    Now you can calculate 7173 + 88503 = 106676. So the result is 6676 which is 4929 in decimal, which is the expected result.