File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Meaningless Drivel and the fly likes Rounding decimal number to nearest 0.05 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Meaningless Drivel
Bookmark "Rounding decimal number to nearest 0.05" Watch "Rounding decimal number to nearest 0.05" New topic
Author

Rounding decimal number to nearest 0.05

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

I want to round decimal number to nearest 0.05. Let me know if the following examples are correct.

12.325 becomes 12.33 and gets rounded to 12.35.
12.315 becomes 12.32 -> 12.30
12.323 ->12.32->12.30
12.399->12.40
12.385->12.40
thanks


Groovy
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

Anyone ?
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Rules for Rounding


My blood is tested +ve for Java.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

Thanks Chetan.
Actually the formula is quite simple

Round(A*20)/20.
 
wood burning stoves
 
subject: Rounding decimal number to nearest 0.05
 
Similar Threads
Math.round errors?
round
how to display negative values within parenthesis using <display:column > ?
rounding off in java
round()