Converting Base Numbers Directly Without Using Base 10Date: 01/26/2004 at 01:53:32 From: John Subject: Bases changes How do you convert from one base to another without going through base 10? I understand conversions between binary based bases, but how do I go from base 3 to base 7, for instance? Would the same algorithm work to go from base 5 to base 12? Date: 01/26/2004 at 13:14:00 From: Doctor Greenie Subject: Re: Bases changes Hi, John -- The process is straightforward and can be used to convert between any two bases. But to use it you need to be proficient in the arithmetic of both the bases you are working with. The key to the process is the method you use to evaluate a number in a particular base. Given the base-10 number "1234", there are two basic ways to evaluate it: (1) (using place values) 1*1000 + 2*100 + 3*10 + 4 = 1000 + 200 + 30 + 4 = 1234 (2) ("building" the number from left to right using only the base) With this method, you start from the left in the number; for each digit, you add that digit and then multiply by the base: 1 ["add" the next (first) digit] 1 * 10 = 10 [multiply by the base] 10 + 2 = 12 [add the next digit] 12 * 10 = 120 [multiply by the base] 120 + 3 = 123 [add the next digit] 123 * 10 = 1230 [multiply by the base] 1230 + 4 = 1234 [add the next digit] I used a base-10 example first so you could see the process; let's use the two methods to evaluate 1234 (base 5): (1) (using place values) 1*125 + 2*25 + 3*5 + 4 = 125 + 50 + 15 + 4 = 194 (2) ("building" the number from left to right using only the base) 1 1 * 5 = 5 5 + 2 = 7 7 * 5 = 35 35 + 3 = 38 38 * 5 = 190 190 + 4 = 194 You can convert directly between any two bases using the second method described above--you just need to be able to do the required arithmetic in the bases you are working with. Following is a demonstration of the conversion 1234 (base 5) = ??? (base 7) We use method (2) above, doing the arithmetic in base 7.... 1 * 5 = 5 5 + 2 = 10 (again, you need to know that 7 in base 7 is 10) 10 * 5 = 50 50 + 3 = 53 53 * 5 = 361 361 + 4 = 365 Note that the arithmetic is all in base 7 (the "new" base), while the multiplication at each stage is by 5 (the "old" base). Checking this result--by evaluating 1234 (base 5) and 365 (base 7) using our familiar base-10 arithmetic--we have 1234 (base 5): 1 1 * 5 = 5 5 + 2 = 7 7 * 5 = 35 35 + 3 = 38 38 * 5 = 190 190 + 4 = 194 365 (base 7): 3 3 * 7 = 21 21 + 6 = 27 27 * 7 = 189 189 + 5 = 194 And one more example: following is a demonstration of the conversion 1234 (base 7) = ??? (base 5) We use method (2) above, doing the arithmetic in base 5. Note that in this example the (base 5) arithmetic is complicated by the fact that our multiplier (the old base, 7) is "12" in base 5.... 1 1 * 12 = 12 12 + 2 = 14 14 * 12 = 223 223 + 3 = 231 231 * 12 = 3322 3322 + 4 = 3331 To check this result, we use our familiar base-10 arithmetic to evaluate both 1234 (base 7) and 3331 (base 5): 1234 (base 7): 1 1 * 7 = 7 7 + 2 = 9 9 * 7 = 63 63 + 3 = 66 66 * 7 = 462 462 + 4 = 466 3331 (base 5): 3 3 * 5 = 15 15 + 3 = 18 18 * 5 = 90 90 + 3 = 93 93 * 5 = 465 465 + 1 = 466 If you followed the preceding examples with pencil and paper, trying to perform the additions and multiplications in the unfamiliar bases, you probably had considerable difficulties. For this reason, when converting between two unfamiliar bases, it is easier to convert first from the "old" base to base 10 and then from base 10 to the "new" base, because all the arithmetic in both those steps can be done in our familiar base 10. I hope all this helps. Please write back if you have any further uestions about any of this. - Doctor Greenie, The Math Forum http://mathforum.org/dr.math/ Date: 08/22/2015 at 10:53:38 From: Shweta Subject: Base Conversion of fractional number(321.42) without base10 Hey, The post above shows how to convert a number from one base to another without first converting it to base 10. But I want to know how to convert a number from one base to another without converting it to base 10 when there's a decimal point in it. For example, convert 321.42 (base 6) to base 7. I know how to convert from base 6 to base 10, and from base 10 to base 7. But I want to know how to convert the 0.42 (base 6) to base 7, bypassing the step to convert to base 10. Date: 08/22/2015 at 11:39:49 From: Doctor Peterson Subject: Re: Base Conversion of fractional number(321.42) without base10 Hi, Shweta. Do you know how to convert fractional numbers between bases? You just do the same thing you'd do converting either to or from base 10, but do your arithmetic in the base you are converting to or from. The same will be true for your question. Show me how you'd convert 0.42_six to base 10, or 0.43_ten to base 7, and I'll show you how to adapt that (if you haven't already done it). - Doctor Peterson, The Math Forum http://mathforum.org/dr.math/ Date: 08/22/2015 at 12:15:14 From: Shweta Subject: Base Conversion of fractional number(321.42) without base10 Thank you for replying. Yeah, I do know how to convert 0.42(base 6) to base 10, and then base 10 to base 7. First, 0.42 (base 6) to base 10 -> 0.42 (base 6) = 4*6^-1 + 2*6^- 2 = 0.722 (base 10) From there, 0.722 (base 10) to base 7 -> 0.722*7 = 5.054 -> 5 0.054*7 = 0.378 -> 0 0.378*7 = 2.646 -> 2 0.646*7 = 4.522 -> 4 And so on. So, 0.42 (base 6) = 0.5024 (base 7). This is what my teacher taught me. But I am unable to figure out how to convert from base 6 to base 7 directly. Date: 08/22/2015 at 13:02:20 From: Doctor Peterson Subject: Re: Base Conversion of fractional number(321.42) without base10 Hi, Shweta. There is a quicker way to convert a fractional number to base 10. I show several methods for conversions in both directions here: Fraction/Decimal Conversion to Other Bases http://mathforum.org/library/drmath/view/55744.html The best method, I think, is to repeatedly divide by the base, then add in the next digit, starting at the far end: 0.42_six, to base ten farthest digit is 2: 2/6 = 0.333... add next digit and divide again: 4.333.../6 = 0.722... To use this method (or yours) to convert to base 7, we would need to do the arithmetic, largely division, in base 7. I'd rather avoid dividing in any unusual base, because it takes a lot of skill. Your method for converting FROM base 10 is a good one, and it uses multiplication, which is easier to do in an unfamiliar base. So I'd use that method for conversion from base 6 to 7, doing the arithmetic in the original base, 6. The method, again, is to multiply by the new base, take the integer part as a digit in the answer, and repeat using the fraction part that remains. Let's do it: 0.42_six to base seven, working in base six: New base, written in base six, is 11_six 0.42_six * 11_six = 5.02 --> 5 0.42_six 0.02_six 0.22_six * 11 * 11 * 11 0.02_six * 11_six = 0.22 --> 0 ---- ---- ---- 42 2 22 0.22_six * 11_six = 2.42 --> 2 42 2 22 ---- ---- ---- 0.42_six * 11_six = 5.02 --> 5 5.02_six 0.22_six 2.42_six So our answer is 0.5025..._seven. This differs from your answer because you rounded the answer in base ten before converting to base seven. (Using a calculator to help with the work, I wouldn't have rounded anything, but the calculator would still be limited in its precision.) I could continue this method for as many places as I want, with no loss of precision. That's a benefit I'd never thought of in years of advising students not to bother converting directly! This could have been a lot more painful, so thanks for offering a problem in which the multiplications were simple! - Doctor Peterson, The Math Forum http://mathforum.org/dr.math/ Date: 08/22/2015 at 13:36:00 From: Shweta Subject: Thank you (Base Conversion of fractional number(321.42) without base10) Thank you, now I get it. All the other students in my class solved it the other way, converting to base 10 and back again. But I was just curious to find how to convert it directly. Thanks again. You were very helpful. |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2015 The Math Forum
http://mathforum.org/dr.math/