在Java中从一种基础转换为另一种基础
发布于 2021-01-31 15:32:28
现在,我正在尝试找到一种方法,将数字从Java中的一个基数转换为另一个基数,给定一个数字,该数字所在的基数以及要转换为的基数。
public static void BaseConversion(String number, int base1, int base2){
//convert the number from one base to another
}
我找到了JavaScript的解决方案,并且想知道是否可以在Java中执行类似的操作:
function convertFromBaseToBase(str, fromBase, toBase){
var num = parseInt(str, fromBase); //convert from one base to another
return num.toString(toBase);
}
关注者
0
被浏览
92
1 个回答