gpt4 book ai didi

java - 四舍五入 - 几十

转载 作者:太空狗 更新时间:2023-10-29 16:07:54 28 4
gpt4 key购买 nike

我现在开始使用 android 和 java,但遇到了问题。

I have a result x = 206.0548.
And y = 206, both of type double
How do I get the result is always rounded up to 210?

In other cases, assuming x = 203.5231 I wanted to round to 205.
If x = 201 to 205 round off.
If x = 198.25 round off to 200.

...谢谢

最佳答案

数学.ceil(x/5) * 5;我认为。查找 Math.ceil 方法,因为这是最好的方法。

关于java - 四舍五入 - 几十,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9688271/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com