Search code examples
javaprecisiondivisionbigdecimal

Preserve maximum precision for intermediate results when dividing BigDecimals


I do a couple of calculations with BigDecimal, before I return the final result. My calculations contain two divisions. I'm aware of the fact that I should define a scale and rounding mode when calling divide(). However, since I'm working with currencies, I want to preserve maximum precision as long as possible and only round my final result to two decimal places.

What scale and rounding mode should I apply to intermediate results for maximum precision?


Solution

  • Usually in physics we take one more digit for intermediate results.