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...(Itwasntme)
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:




So
(the remainders).
and the other direction:

(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
to an octal, eight based number, i first need to convert to
, 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!
Re: convertion between numeral systems
Re: convertion between numeral systems
Hi, Soroban!
briliant.
didn't think about it...
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!
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... 