# Conversion to base $9$

Where am I going wrong in converting $397$ into a number with base $9$?

$397$ with base $10$ $$= 3 \cdot 10^2 + 9 \cdot 10^1 + 7 \cdot 10^0$$ To convert it into a number with base $9$ $$3 \cdot 9^2 + 9 \cdot 9^1 + 7 \cdot 9^0 = 243 + 81 + 7 = 331$$ But answer is $481$?????

• You started with a number in base $9$ and converted it to base $10$ rather than the reverse. – N. F. Taussig Aug 28 '17 at 15:51
• To convert to base $9$ from base $10$, you could find the highest power of $9$ (e.g. $9,81,729$ ...) that is less than your number, then the largest multiple of that power that is still less than your number will be your left-most digit. So, in the case of $397_{10}$, the largest power of $9$ that will fit is $81$ (since $729$ is too large), and you can fit four $81$s: $4 \cdot 81=324< 397$ (five is too many, since $5 \cdot 81 = 405 > 397$. This means that the leftmost digit must be $4$. We are left with $397 - 4 \cdot 81 =73$. Now, find the largest multiple of $9$ that's less than $73$, etc. – Zubin Mukerjee Aug 28 '17 at 15:56
• The operation you've done is convert $(397)_9$ to base $10$. – Thomas Andrews Aug 28 '17 at 16:04
• One obvious sanity check is that if converting from a bigger base to a smaller number you should get a larger answer and visa versa. You can easily check your answer by converting it back to decimal to see if you get what you started with. – Warren Hill Aug 28 '17 at 16:20

$481_{[9]} = 4\,\cdot\,81 +8\,\cdot9+1\,\cdot\,1 = 324 + 72 + 1 = 397_{[10]}$

The conversion you presented is incorrect, you converted $397_{[9]}$ into $331_{[10]}$, which is not what you want.

To convert it properly:

$397/9 = 44$ (remainder = $1$)

$44/9 = 4$ (remainder = $8$)

$4/9 = 0$ (remainder = $4$)

The remainders give the result: $\boxed{397_{[10]}=481_{[9]}}$

You cannot simply keep the same coefficients but change the $10$'s to $9$'s. What you must do is something like the following: \begin{align}397&=3\times \color{red}{10}^2+9\times\color{red} {10}^1+7\times \color{red}{10}^0\\&=3\times(9+1)^2+9\times(9+1)+7\times 1\\&=3\times\color{blue}9^2+(3\times18+3)+\color{blue}9^2+\color{blue}9^1+(7)\\&=4\times \color{blue}9^2+(6\times9)+(10)+\color{blue}9^1\\&=4\times \color{blue}9^2+8\times \color{blue}9^1+1\times \color{blue}9^0\end{align}

What you did was simply change the tens in red to nines without doing any intermediate steps.

• I love that the three answers right now are all using different methods to convert bases :) – Zubin Mukerjee Aug 28 '17 at 16:03
• I had not seen this method before but it's a nice approach. I would have used repeated division and took the remainders as @DanielCunha did because that's the way I was taught to convert decimal to binary but it works with any base. – Warren Hill Aug 28 '17 at 16:08
• @WarrenHill I sometimes use this approach, especially when the bases are so close together (like $9$ and $10$ are only $1$ apart, so you only pick up small numbers with the bracket expansion). – Dave Aug 28 '17 at 16:10
• @Warren We can do this much more efificiently if we exploit the recursive Horner form of radix notation - see my answer. – Bill Dubuque Aug 28 '17 at 16:41

The problem is that

$$(397)_{10} = 3 \cdot 10^2 + 9 \cdot 10^1 + 7 \cdot 10^0 \ne 3 \cdot 9^2 + 9 \cdot 9^1 + 7 \cdot 9^0 = (397)_9.$$

What we are trying to do is solve

$$(397)_{10} = 3 \cdot 10^2 + 9 \cdot 10^1 + 7 \cdot 10^0 = a \cdot 9^2 + b \cdot 9^1 + c \cdot 9^0 = (abc)_9$$

To find $a$ we take as many copies of $81$ from $397$ as we can:

$$397 - 4 \cdot 81 = 73.$$

Thus $a = 4$. Next, we take as many copies of $9$ from $73$ as we can:

$$73 - 8 \cdot 9 = 1,$$

so $b = 1$. Lastly, we take as many copies of $1$ from $1$ as we can:

$$1 - 1 \cdot 1 = 0.$$

Hence $c = 1$. Therefore the answer is $$(397)_{10} = (481)_9.$$

• Nice answer, +1! I think you should mention that $9^3 = 729>397$ is too large to be considered, which is why you are starting from $9^2 = 81$, instead of a higher power of $9$. Cheers – Zubin Mukerjee Aug 28 '17 at 16:02

Here is a layout of the conversion algorithm (successive Euclidean divisions) $$\begin{array}{ccrcrc*{10}{c}} &&44&&4 \\ 9&\Bigl)&397&\Bigl)&44&\Bigl)& \color{red}{\mathbf 4}\\ &&\underline{36}\phantom{7}&&\underline{36}\\ &&37&&\color{red}{\mathbf 8} \\ &&\underline{36} \\ &&\color{red}{\mathbf 1} \end{array}$$ This is based on Horner's scheme: \begin{align} [397]_{10}&=9\cdot 44+ \color{red}1=9(9\cdot 4+\color{red}8)+\color{red}1=9^2\cdot\color{red}4+9\cdot\color{red}8+1\cdot \color{red}1. \end{align}

• But no division is needed if we use Horner optimally - see my answer. – Bill Dubuque Aug 28 '17 at 16:39
• That''s fine but it's no so easy in practice to do operations in another base, especially if you have to carry digits. – Bernard Aug 28 '17 at 17:14

As I explained in 2011, one easy way is to write the number in Horner form in the original base, then do the base conversion from the inside-out, e.g. below where $\rm\color{#c00}{red}$ means radix $9$ notation

\begin{align} 397 \,&=\, (3\cdot 10\, +\, 9)\,10 +7\\ &=\, (\color{#c00}{3\cdot 11+10})10+7\\ &=\qquad\quad\ \ \color{#c00}{43\cdot 11}+7\\ &=\qquad\qquad\ \ \ \color{#c00}{473}+7\\ &=\qquad\qquad\ \ \ \color{#c00}{481}\end{align}