public static String double_to_code(String data){
char[] hexChars = data.toCharArray();
int len = hexChars.length;
byte[] bytes = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
String hexPair = String.valueOf(hexChars[i])+String.valueOf(hexChars[i + 1]);
bytes[i / 2] = (byte) Integer.parseInt(hexPair, 16);
}
long longValue = 0;
for (byte b : bytes) {
longValue <<= 8;
longValue |= b & 0xFF; // 右移并按位或
}
// 或者使用 BigInteger
BigInteger bi = new BigInteger(1, bytes);
longValue = bi.longValue();
double doubleValue = Double.longBitsToDouble(longValue);
String strValue = String.format("%.2f", doubleValue); // 保留两位小数
return strValue;
}
12-29
3771

12-07
218
