Thursday, April 16, 2009

Use BigDecimal for financial calculations

It is common to use the Double object or the double primitive type for financial calculations. Since you have no control over rounding behavior, mistakes may arise in your calculations. You might charge customers more (or less) than they owe. Use BigDecimal to solve this problem. For a clear, thorough explanation, see this document.

No comments: