posted 13 years ago
It's just simply because of the way IEEE floating-point numbers are represented and calculated. They are stored as complicated binary entities, not as strings like "123.45". Whenever floating-point math is performed, you have to account for minute precision loss. If you want to show the user a number with 2 decimal digits of precision, then just use the java.text.NumberFormat-related classes to format the result, and it will look fine. But you can't guarantee that the number in memory is exact - just very close.