Jes*_*per 10
适当格式化.例如:
System.out.printf("%.1f", 1654621658874684.0);
Run Code Online (Sandbox Code Playgroud)
或者您可以像字符串一样使用它:
//"%.1f" this mean, how many number after the comma
String value = String.format("%.1f", 1654621658874684.0);
Run Code Online (Sandbox Code Playgroud)
请注意,这double不是无限精确的.它的精度约为15到17位十进制数.如果需要具有任意精度的浮点数,请使用BigDecimal而不是double.
| 归档时间: |
|
| 查看次数: |
8135 次 |
| 最近记录: |