爪哇 - 转换十六进制IEEE-754 64位浮点 - 双precision [英] Java - Convert hex to IEEE-754 64-bit float - double precision
问题描述
我想下面的十六进制字符串转换:41630D54FFF68872为9988776.0(浮动-64)
I'm trying to convert the following hex string: "41630D54FFF68872" to 9988776.0 (float-64).
通过一个单一的precision浮动-32我会做的:
With a single precision float-32 I would do:
int intBits = Long.valueOf("hexFloat32", 16).intValue();
float floatValue = Float.intBitsToFloat(intBits);
但这会引发:java.lang.NumberFormatException:无限或NaN使用上面的64位十六进制时
but this throws a: java.lang.NumberFormatException: Infinite or NaN when using the 64-bits hex above.
我要如何转换为十六进制为双precision浮动连接codeD和IEEE-754 64位?
How do I convert a hex to a double precision float encoded with IEEE-754 with 64 bits?
感谢您
推荐答案
您想要双precision,所以浮动是不正确的阶级 - 这对单个precision
You want double-precision, so Float isn't the right class - that's for single precision.
相反,你想要的双类,特别是<一个href="http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Double.html#longBitsToDouble%28long%29"相对=nofollow> Double.longBitsToDouble 。
Instead, you want the Double class, specifically Double.longBitsToDouble.
这篇关于爪哇 - 转换十六进制IEEE-754 64位浮点 - 双precision的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!