BigDecimal rounding fun

L

laredotornado

Hi,

I'm using Java 1.6. BigDecimal division seems to be rounding to the
tenths decimal place and I would prefer it round to the hundredths
decimal place. I have

final BigDecimal avgRate = sum.divide(totalDays,
BigDecimal.ROUND_HALF_EVEN);

If totalDays is 6, and sum is 634, the result above is giving me
105.7, but ideally, I would want 105.67 (since the result is
105.666667). Any ideas how to adjust the division above to get the
result I want?

Thanks, - Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top