Base conversion from any base to any other base

andrewtheart

New member
Joined
Jan 29, 2010
Messages
1
Hello Free Math Help members --

I've searched Google in vain, trying to determine a simple algorithm for converting any number in any base, to any other number in any other base. (For example -- 1234 base 3 to base 14).

Right now, I can convert from base 10 number to any other base, and any base to base 10. I'm going to describe what I do below for documentation's sake --

To convert from base 10 number to any other base, I simply continuously divide the number by the base to convert to, and the remainders become the number in the new base (basically, I use long division). Simple example -- 123 base 10 in base 16 (hex).

Steps I take --

* Divide number to convert by new base, writing out remainder: Divide 123 by 16, get 7 R 11.
* Divide result from last division by new base, writing out remainder: Divide 7 by 16, get 0 R 7.
* The remainders are 11 and 7. "11" in hex is actually B, so the remainders are B and 7. Print this out in reverse and you have 7B. That is the answer.

To convert from a number in any base to base 10, I multiply each "place" in the number, starting from the right, by the new base raised to the "place" number. Then I add the results together. Simple example -- 7B base 16 (hex) in base 10.

Steps I take --

* Multiply number on very right by base raised to placeholder number: B x (16^0) = (11) * (1) = 11
* Multiply next number, going left, by base raised to placeholder number: 7 x (16^1) = (7) * (16) = 112
* Add products: 11 + 112 = 123

My question is: How do I reliably go from base x to base y on paper, if they do not fall into these two categories? I can't figure it out! I've searched for a day. I have a feeling it requires converting the number to base 10, using my second method, and converting that to the new base. But is there a shortcut? And if there is not, what is the theory behind why, on paper, you can't do a direct conversion?

Thanks for any and all help.

On another note -- if anyone knows how to add and multiply binary and/or add and subtract hex, that would be good to know too!
 
It isn't so bad converting from base X to base Y if log_X(Y) is an integer. I'll do an example converting integers in Z_2 (binary) to Z_16 (hex).

2^4=16, so we group the digits in sets of 4

0101101111011001 = 0101 1011 1101 1001

Now each block is at most F, so we convert directly:

0101101111011001 = 5BD9.

The same would work going from 3->9 (blocks of 2), 5->625, etc.

.....

In general, converting to base 10 involves summing up the digits times the base to their relative location in the digit representation. We can do the same in ANY base.

I will do the example above (well, half of it) using this method.

11011001 = 2^7 + 2^6 + 2^4 + 2^3 +2^0 = 80 + 40 + 10 +8 + 1 = D9

The issue is we don't have fingers for A,B,C,D,E,F (counting one of our fingers as 0) so its not "normal" for us do think this way. You can train yourself to do this if you truly wanted to.
 
Top