【发布时间】:2018-06-04 23:00:06
【问题描述】:
当使用 Double.parseDouble(stringValue) 将 0.0001 从字符串转换为双精度时,返回 1.0E-4。如何获得 4 位小数的双精度值 0.0001。
【问题讨论】:
-
String.format("%.4f",secondNumber);
-
0.0001 是一个字符串,我希望输出为双倍。与 0.0001 完全相同,而不是字符串。
-
@AndEngine 但是1.0E-4 is exactly the same as 0.0001 就数据如何存储为双精度而言。当您在记录输出时转换回字符串时,您只会得到不同的表示形式。
标签: android string type-conversion double