void test (){
int s = 616626
String a = s.toRadixString(16)
print('十进制转16进制---$a')
int m = _hexToInt(a)
print('十六进制转10进制---$m')
}
int _hexToInt(String hex) {
int val = 0
int len = hex.length
for (int i = 0
int hexDigit = hex.codeUnitAt(i)
if (hexDigit >= 48 && hexDigit <= 57) {
val += (hexDigit - 48) * (1 << (4 * (len - 1 - i)))
} else if (hexDigit >= 65 && hexDigit <= 70) {
// A..F
val += (hexDigit - 55) * (1 << (4 * (len - 1 - i)))
} else if (hexDigit >= 97 && hexDigit <= 102) {
// a..f
val += (hexDigit - 87) * (1 << (4 * (len - 1 - i)))
} else {
throw new FormatException("Invalid hexadecimal value")
}
}
return val
}