1.十进制数据转为其它进制
private String toRadix(int data,int radix){
char[] digits={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char buf[] = new char[33];
int charPos = 32;
while(data>radix){
buf[charPos--]=digits[data % radix];
data=data/radix;
}
buf[charPos] = digits[data];
return new String(buf, charPos, (33 - charPos));
}
2.将26进制数据转为10进制
private Long trans(String s) {
s = s.toLowerCase();
Long sum=0L;
for(int i=0;i<s.length();i++){
sum+=(long) ((s.charAt(i)-'a')*Math.pow(26,s.length()-1-i));
}
return sum;
}