Originally posted by Vasim Patel: How do I round off the decimal in java to the nearest .05
Since 0.05 is a decimal number, and float/double are binary approximations of decimal numbers, you can't be guaranteed to round exactly using them. If you just want to get close, try this:In words, you shift the rounding scale to be 1 instead of 0.05, round the value to nearest integer, and shift back. If you need exact decimal values, use java.math.BigDecimal.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com