Code example for MathContext

0
        a = new BigDecimal("92345678901234567.8");
        b = new BigDecimal("43");
        res = a.multiply(b);
        assertEquals("incorrect value", "3970864192753086415.4", res.toString());
 
        mc = new MathContext(20, RoundingMode.DOWN);
        a = new BigDecimal("3970864192753086415.4");
        b = new BigDecimal("92345678901234567.8");
        b = new BigDecimal("92345678901234567.8001");
        assertEquals("incorrect value", "43",
                a.round(mc).divideToIntegralValue(b.round(mc)).toString());
        res = a.divideToIntegralValue(b, mc);
        assertEquals("incorrect value", "42", res.toString());
 
//        mc = new MathContext(1, RoundingMode.DOWN); 
//        res = a.divideToIntegralValue(b, mc); 
//        assertEquals("incorrect value", "42", res.toString()); 
 
 
        mc = new MathContext(17, RoundingMode.FLOOR);
        a = new BigDecimal("518518513851851830");