How can I print a double in standard notation?
double h = 104857600 - 32;
System.out.println(h);
Run Code Online (Sandbox Code Playgroud)
Result:
1.04857568E8
Run Code Online (Sandbox Code Playgroud)
Desired result:
104857568
Run Code Online (Sandbox Code Playgroud)
You can use printf()
System.out.printf("%.0f", h);
Run Code Online (Sandbox Code Playgroud)
The 0 is the precision, you can modify it.
Edit:
If you want to store it as a String, you can use String.format("%.0f", h).
| 归档时间: |
|
| 查看次数: |
277 次 |
| 最近记录: |