[英]Unwrapping double to a string in java
In Java, for storing large numbers(10^80 to 10^100), we will be using Double
. 在Java中,为了存储大量数字(10 ^ 80至10 ^ 100),我们将使用
Double
。 But Double
will return in ae^x format where x is exponent value.Is there any way to unwrap it to a string. 但是
Double
会以ae ^ x格式返回,其中x是指数值,是否有任何方法可以将其解包为字符串。
Eg: Double d = 1000000000;
例如:
Double d = 1000000000;
Double.toString(d); --> output: 1.0E9.
Instead I want it as 1000000000 相反,我希望它为1000000000
Use a DecimalFormat
: 使用
DecimalFormat
:
double d = 1000000000;
DecimalFormat df = new DecimalFormat("#");
System.out.println(df.format(d));
From the Javadocs: 从Javadocs:
Integer: MinimumInteger # # Integer # , Integer
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.