You are not logged in.
Pages: 1
I would like to learn how to convert from any base to any other base.
I already know how to convert from decimal to any base and from any base to decimal.
My question:
Can I covert between bases by using the decimal base as an intermediary step.
I mean say I have to convert from say base seven to base 5. Can I convert from base seven to base 1o, and then from base 10 to base 5 effectively?
Offline
The answer is yes.
Offline
I never thought that you could do that without converting first to base ten
"There is not a difference between an in-law and an outlaw, except maybe that an outlaw is wanted"
Nisi Quam Primum, Nequequam
Offline
example johnny. (let b[n] be the current base of the number)
converting to base 10 as an intermediate step
123b4 -> 1×4²+2×4+3 = 27b10
27b10 -> 16+11 -> 16+8+3 -> 16+8+2+1 = 11011b2
123b4 = 11011b2 = 27b10
to convert straight to another base, you have to go through each digit like this:
123b4:
3b4 = 1b4 + 2b4 = 1b2 + 10b2 = 11b2
20b4 = 2b4×10b4 = 10b2×100b2 = 1000b2
100b4 = 1b4×10b4×10b4 = 1b2×100b2×100b2 = 10000b2
123b4 = 11b2 + 1000b2 + 10000b2 = 11011b2 = 27b10
its clearly a bit more long-winded, but it does work.
then back to base 4
11011b2:
1b2 = 1b4
10b2 = 1b2×10b2 = 1b4×2b4 = 2b4
1000b2 = 1b2×10b2×10b2×10b2 = 1b4×2b4×2b4×2b4 = 2b4×10b4 = 20b4
10000b2 = 10b4×10b4 (from above) = 100b4
11011b2 = 1b4 + 2b4 + 20b4 + 100b4 = 123b4
the reason why i go through each digit like that, is it means that any addition does not carry forward to the next digit, so you don't have to worry about adding numbers of more than 1 digit of different bases which i find confusing.
Last edited by luca-deltodesco (2007-11-10 00:12:06)
The Beginning Of All Things To End.
The End Of All Things To Come.
Offline
Pages: 1