# Math Help - convertion between numeral systems

1. ## convertion between numeral systems

Hi guys.
i'm new here.
English isn't my first language, so you'd have to forgive me for any mistakes you might find...

I couldn't find more suitable place to post it, and i hope this is the right forum for my question...

So, i want to be able to convert numbers from one base to another.
i know how to do it from any given (decimal) number, to any other base.

Say i want to convert the number 347:

$347/6=57, R=5$
$56/6=9, R=3$
$9/6=1, R=3$
$1/6=0, R=1$

So $347_{10}=1335_{6}$ (the remainders).

and the other direction:

$1335_{6}=5\cdot6^0+3\cdot6^1+3\cdot6^2+1\cdot6^3=3 47_{10}$

(the reason i'm showing the calculation here is because i would love to hear about a better, faster way to convert numbers from base to base)

my problem is:
i want to be able to convert numbers from base to base directly.
for example: if i want to convert $1335_{6}$ to an octal, eight based number, i first need to convert to $347_{10}$, and only then i'm able to convert to an octal number.

is there a way to skip the decimal conversion part and go straight to the octal number?
if so, how can it be done?

thanks in advanced, and have a nice day!

2. ## Re: convertion between numeral systems

Hello, Stormey!

I want to be able to convert numbers from base to base directly.

For example: if i want to convert $1335_{6}$ to an octal, base-8 number,
I first need to convert to $347_{10}$, and only then i'm able to convert to an octal number.

Is there a way to skip the decimal conversion part and go straight to the octal number?
If so, how can it be done?

It can be done, but you must be able to do the division in base-6.

It looks like this . . .

. . $\begin{array}{ccccccc} &&&& 1&1&1_6 \\ &&& --&--&--&-- \\ 1&2_6&|&1&3&3&5_6 \\ &&& 1&2 \\ &&& --&-- \\ &&&& 1&3 \\ &&&& 1&2 \\ &&&& --&-- \\ &&&&& 1&5 \\ &&&&& 1&2 \\ &&&&& --&-- \\ &&&&&&3 \end{array} \quad \boxed{R\,=\,3}$

. . $\begin{array}{cccccc} &&&&& 5_6 \\ &&& --&--&-- \\ 1&2_6&|&1&1&\;1_6 \\ &&& 1&0&4 \\ &&& --&--&-- \\ &&&&& 3 \end{array} \quad \boxed{R\,=\,3}$

. . $\begin{array}{cccc} &&& 0_6 \\ &&& -- \\ 1&2_6&|&5_6 \\ &&& 0\; \\ &&& -- \\ &&&5 \end{array} \quad \boxed{R \,=\,5}$

Therefore: . $1335_6 \;=\;533_8$

3. ## Re: convertion between numeral systems

Hi, Soroban!

briliant.
but the truth is i'm supposed to write an algorithm for it, and since the compiler only divides in decimal base, it seems now that division in base 6 (or any other base besides decimal, for that matter) will require some more work.
i'll need another algorithm for a predesignated function that divides numbers in any given base (defined by the user).
thats just going to complicate things, and therfore leaves me with the first idea:
a two steps conversion (from x based number to decimal, and from decimal to y based number).

thanks for the help, and have a nice day!

4. ## Re: convertion between numeral systems

Hi Soroban.
after seeing that two conversions isn't a picnic either, i'll need to consider it after all.

so i just need to ask something:
you said that the division needs to be in base-6. why did you divided 1335 by 12 and not by 6?

edit.

OK... i see what you did there... $8_{10}=12_6$