Java和小数E数

And*_*rew 4 java

大家好,圣诞快乐.

我试图谷歌这个,也看看StackOverflow但我无法弄清楚如何解释这个.

Java与我之前使用过的其他语言略有不同.它提供了像9.870699812169277E-4这样的数字

我该如何解读?有没有办法在Java中解析它并显示没有那个E?

非常感谢.

use*_*882 10

您可以使用NumberFormat.

Code

// you can format to any output you want
NumberFormat formatter = new DecimalFormat("0.00000000000");
String string = formatter.format(9.870699812169277E-4);
System.out.println(string);
Run Code Online (Sandbox Code Playgroud)

Result

0.00098706998
Run Code Online (Sandbox Code Playgroud)

有关

Java:带有小数的格式doublejava中的格式号