Java实现十六进制转浮点数

1)使用BigInteger与16进制之间的转化

// 16进制转大数值
new BigInteger("419e6666", 16);

2) 使用 Float.intBitsToFloat() 方法

//参数为 int 类型的二进制、八进制、十六进制
Float.intBitsToFloat(1100899942)

该方法支持带符号转换,示例代码及运行效果:

Float f = Float.intBitsToFloat(new BigInteger("419e6666", 16).intValue());
System.out.println(f);

419e6666十六进制字符串转浮点数结果为:19.8

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_40042416/article/details/127800609