2012-03-13 5 views
2

今はアンドロイドと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. 

は...

+0

5刻みで丸めたいですか?有効な結果は0,5,10,15,20、...となりますか? – zapl

+0

200と201の間の値はどうですか? – jpm

+0

ラウンドがザッププと言われているごとに、5 – GDawson

答えて

7

Math.ceil(X/5)* 5ありがとう。 だと思います。それが最善の方法であるので、Math.ceilメソッドを見てください。

+0

毎にOPが尋ねるのと全く同じです。投票アップ: – TerryProbert

+0

非常に良い、感謝の友人 – GDawson