Mark said:
Actually it isn't always exact either, it is just that it requires a
particular form of inexactness where the rules have been specified
assuming base 10.
This does suggest some rules of thumb:
1. If the calculation is expected to be truly exact, no rounding at all,
either do it in an integer type, or use BigDecimal with rounding mode
UNNECESSARY. BigDecimal may be better because it will throw an exception
if any calculation is rounded, where int or long would silently truncate.
2. If the calculation has specified base 10 rounding rules do it in
BigDecimal with the appropriate rounding mode. Do not even think about
double. Accounting for a loan as it is being repaid falls in this category.
3. If rounding is necessary but not specified, there is more flexibility
and double may be appropriate, especially if the calculation requires
functions such as logarithms. This category includes necessarily inexact
financial projections.
Patricia