舍入 - 数十个

时间:2012-03-13 16:41:57

标签: java android double

我现在开始使用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.

...谢谢

1 个答案:

答案 0 :(得分:7)

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