Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想用小数点后 5 位舍入值。
我试过Math.round(x * 10000) / 10000了,但它不起作用。
Math.round(x * 10000) / 10000
您可以尝试以下代码进行更珍贵的四舍五入,一般我们使用这些来计算保险数据:
BigDecimal decimal = new BigDecimal(100); decimal.round(new BigDecimal(10000).setScale(5,BigDecimal.ROUND_DOWN);
在选择天花板选项时要小心。请参阅大十进制以获取更多选项。