wood burning stoves*
The moose likes Beginning Java and the fly likes round Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "round " Watch "round " New topic
Author

round

deep rai
Ranch Hand

Joined: Oct 04, 2007
Posts: 56
hi,

I need to round eg: 16.490000000000002 to 16.49 (rounded up to the nearest 0.05) i tried this
Math.ceil(value/0.05)*0.05

considering 0.05 as round factor ,but its still the same. Any help is appreciated.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Look at the java.text.DecimalFormat class.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
Don't get me started about those stupid light bulbs.
 
subject: round