What will you expect from the following code?
Instead of printing “0.90″, it prints “0.9000000000000004″ on my machine.
This is a know floating point issue with all languages. To get it correctly done in Java, you need to use BigDecimal class, passing the number as string.
For currency calculation, always use BigDecimal.