# BASE CONVERSION

• November 12th, 2010, 05:09 PM
bgwilf
BASE CONVERSION
Can Anyone suggest me a simpler algorithm for converting any base number to base 10??
• November 12th, 2010, 05:16 PM
bgwilf
Re: BASE CONVERSION
USING ITERATION PLZ!!!
• November 12th, 2010, 10:38 PM
Darryl.Burke
Re: BASE CONVERSION
Quote:

suggest me a simpler algorithm
Simpler than what?

db
• November 13th, 2010, 03:35 AM
bgwilf
Re: BASE CONVERSION
At this point it doesn't matter that it is simpler. I just need an Iterative way to implement any base conversion to a base 10.
• November 13th, 2010, 06:03 AM
Darryl.Burke
Re: BASE CONVERSION
Take a pen and paper. Do some base conversion math, placing each step on a separate line. When you're comfortable that you know what steps are needed, write Java code that carries out the same steps.

If and only if you can't get the right results, post your best attempt and we'll take a look.

db
• November 13th, 2010, 11:54 AM
helloworld922
Re: BASE CONVERSION
If you are unsure how to comvert numbers by hand, see PlanetMath: base conversion
• November 13th, 2010, 12:02 PM
bgwilf
Re: BASE CONVERSION
ok thanks! This is what I got and I actually think that it works
Code Java:

``` public static String convert(String num,int b) { int k= num.length(); int num10=0; for(int i=0; i<k ;i++) { String r= num.charAt(k-(i+1))+""; int NUM1 = Integer.parseInt(r); num10 += (NUM1 *power(b,i));   } return num10+""; }```