Converting large numbers from one base to another

953 Views Asked by At

The number I am trying to convert is 212122101212, from base 3 to base 9.

The way I tried doing it is converting the number to base 10 by multiplying each digit with weight of corresponding power of 3. And then convert this to base 9 by repeatedly diving the number by 9 and keeping the remainder.

Since it's a very large number I committed mistakes couple of times while converting it manually. Is there any better, less error prone, way of converting the number?

2

There are 2 best solutions below

0
On BEST ANSWER

Generally, if you are converting from base $n$ to base $n^m$, you can do it by taking the original number $m$ digits at a time starting from the right.

So in your case, take the number 2 digits at a time starting from the right. $21-21-22-10-12-12$ in base 3 converts to $7-7-8-3-5-5$ in base 9($3^2)$ so your answer is $778355$

0
On

$212122101212_3=21|21|22|10|12|12=(2 \times 3+1\times1)3^{10}+(2\times3+1\times1)3^8+(2\times3+2\times1)3^6+(1\times3+0\times1)3^4+(1\times3+2\times1)3^2+(1\times3+2\times1)3^0=7\times9^5+7\times9^4+8\times9^3+3\times9^2+5\times9^1+5\times9^0=778355_9$