Fixed, Floating, & Computation with BigDecimal
by Mike Cowlishaw, Joshua Bloch, and Joseph D. Darcy


Example 1:

BigDecimal rate=new BigDecimal("1.05");
BigDecimal cost=new BigDecimal("0.70");
System.out.println(rate.multiply(cost).setScale(2, BigDecimal.ROUND_HALF_UP));
// displays 0.74

Example 2:
(a)

MathContext mc=new MathContext(7, RoundingMode.HALF_EVEN);
BigDecimal C=A.divide(B, mc);

(b)
MathContext mc=new MathContext(7, RoundingMode.DOWN);
BigDecimal C=A.divide(B, mc);



1


