<<< Comparing Strings | Index | Financial Calculations >>> |
Java double type isn't flexible enough to provide control over how the number is rounded, and there is no way to limit the double precision in computation.
When working with currencies, double types representing dollar amounts often yield rounding errors of $0.01 or more.
For example, where an exact amount is expected, such as $5.00, the rounding error may result in $5.01. It would make development of an accounting software a nightmare, if programmers were forced to use only double type for currency.
The BigDecimal class gives program complete control over rounding behavior of foating point numbers.
Eight rounding modes are provided for the control of rounding, specified by values of the RoundingMode enumeration.
<<< Comparing Strings | Index | Financial Calculations >>> |