Code example for BigDecimal

Methods: toString

0
        assertEquals("incorrect value", "-1.234567890123456789012345678E+44", bd.toString());
 
        mc = new MathContext(33, RoundingMode.CEILING);
        bd = new BigDecimal(biCA, mc);
        assertEquals("incorrect value",  "1.23456789012345678901234567890124E+44", bd.toString());
        bd = new BigDecimal(nbiCA, mc);
        assertEquals("incorrect value", "-1.23456789012345678901234567890123E+44", bd.toString());
 
        mc = new MathContext(34, RoundingMode.UNNECESSARY);
        try { 
            bd = new BigDecimal(biCA, mc);
            fail("No ArithmeticException for RoundingMode.UNNECESSARY");
        } catch (ArithmeticException e) {
            // expected 
        } 
        try { 
            bd = new BigDecimal(nbiCA, mc);
            fail("No ArithmeticException for RoundingMode.UNNECESSARY");
        } catch (ArithmeticException e) {
            // expected 
        }