Posted By:
Michael_Wax
Posted On:
Wednesday, June 6, 2001 09:14 AM
If you are displaying a single value, using double and NumberFormat.format will work. However, for any sort of calculations, using double will result in deviations from the correct results fairly quickly. I have seen the use of double result in discrepancies of a penny or two on actual commercial calculations. While this may seem small (after all, a penny typically corresponds to less than 0.1% of the total value), it is unacceptable in for commercial and financial transactions. If you are building a system for real-world use, you will need to use BigDecimal.
Posted By:
Michael_Wax
Posted On:
Wednesday, June 6, 2001 08:34 AM
If you are displaying a single number, using double with NumberFormat is fine. If you are doing calculations, you will see discrepancies from the actual values very quickly using double and NumberFormat. While the discrepancies may be small (much less than 1%), financial calculations must have absolute accuracy. After all, I know that I would be unhappy if my bank account were off by a few pennies every month. For any real-world application involving money, you need to use BigDecimal.