我正在尝试将以下十六进制字符串:“41630D54FFF68872”转换为 9988776.0 (float-64)。
使用单精度 float-32 我会这样做:
int intBits = Long.valueOf("hexFloat32", 16).intValue();
float floatValue = Float.intBitsToFloat(intBits);
但这会抛出:java.lang.NumberFormatException: Infinite or NaN when using the 64-bits hex above.
如何将十六进制转换为使用 64 位 IEEE-754 编码的 double float ?
谢谢
最佳答案
您需要 double ,因此 Float 不是正确的类 - 这是用于单精度的。
相反,您需要 Double 类,特别是 Double.longBitsToDouble .
关于Java - 将十六进制转换为 IEEE-754 64 位 float - double ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6416269/