在 Java 中,为了存储大数(10^80 到 10^100),我们将使用 Double
。但是 Double
将以 ae^x 格式返回,其中 x 是指数值。有什么方法可以将其解包为字符串。
例如:双 d = 1000000000;
Double.toString(d); --> output: 1.0E9.
相反,我希望它是 1000000000
最佳答案
使用 DecimalFormat
:
double d = 1000000000;
DecimalFormat df = new DecimalFormat("#");
System.out.println(df.format(d));
来自 Javadocs:
Integer: MinimumInteger # # Integer # , Integer
关于java - 在java中将double解包为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29854061/