Non-decimal radices/Convert: Difference between revisions
Content deleted Content added
added C++ version |
|||
Line 174: | Line 174: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
for long's: |
|||
<java>public static |
<java>public static long backToTen(String num, int oldBase){ |
||
return |
return Long.parseLong(num, oldBase); //takes both uppercase and lowercase letters |
||
} |
} |
||
public static String tenToBase( |
public static String tenToBase(long num, int newBase){ |
||
return |
return Long.toString(num, newBase);//add .toUpperCase() for capital letters |
||
}</java> |
}</java> |
||
for BigInteger's: |
|||
<java>public static BigInteger backToTenBig(String num, int oldBase){ |
|||
return new BigInteger(num, oldBase); //takes both uppercase and lowercase letters |
|||
} |
|||
public static String tenBigToBase(BigInteger num, int newBase){ |
|||
return num.toString(newBase);//add .toUpperCase() for capital letters |
|||
}</java> |
|||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
<pre> |
<pre> |