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!
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!