I had a problem to solve in the interview which said that
Digits should be rounded off to a precision level of 0.05
Now i tried out the math formula to do that using Double as the object, but unfortunately, math bug crept in and the resulting value became something like 12.150000000002. Now i have no option but to use the Decimal format.. ..
Doubles are inherently imprecise. If you require exact *numbers*, then BigDecimal is the way to go. But if you require an exact *textual* representation of the rounded number, then the java.text.DecimalFormat class can help.