如何以可读格式打印双精度?

vic*_*rio 1 java format double

例如,我想计算:4,000,000.0 * 4;我得到了这个:1.6E7。我应该怎么做才能得到这个:16,000,000.0?谢谢!!

mcf*_*gan 5

使用 DecimalFormat 如下:

double d = 10000000.00;
DecimalFormat dfmt = new DecimalFormat(",000.0");

System.out.println(dfmt.format(d)); // will display 10,000,000.0
Run Code Online (Sandbox Code Playgroud)