// K进制转10进制
public static int DCHANGE(String NUM, int K) {
int NUM_len = NUM.length();
int total = 0;
while (NUM_len > 0) {
NUM_len -= 1;
total += Integer.parseInt(NUM.charAt(NUM_len) + "")
* Math.pow(K, NUM_len);
}
return total;
}
// 10进制转K进制
public static String RCHANGE(int NUM, int K) {
String total = "";
if (NUM == 0) {
total = "0";
} else {
while (NUM > 0) {
String temp = NUM % K + "";
total = temp + total;
NUM /= K;
}
}
return total;
}
来源:CSDN
作者:bgf_me
链接:https://blog.csdn.net/qq_39882553/article/details/104717792