fd485b154a0427fa75c0428cdafac71f

fd485b154a0427fa75c0428cdafac71f

我正在尝试将字符串转换为双精度。但我收到数字格式异常。给出异常的代码是这样的:

double B = Double.parseDouble(s);


我将s的值从服务器带到我的应用程序。就像这样:

fd485b154a0427fa75c0428cdafac71f


有什么办法吗?

最佳答案

试试这个:(我假设字符串是0-9和a-f的十六进制coz)

double doubleVal = new BigInteger("fd485b154a0427fa75c0428cdafac71f", 16).longValue();
long longVal = new BigInteger("fd485b154a0427fa75c0428cdafac71f", 16).longValue();
System.out.println(doubleVal);
System.out.println(longVal);


这给出:

8.4848548707027374E18
8484854870702737183

关于java - java lang NumberFormatException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11859883/

10-10 20:05