Code example for MathContext

0
 
    public void testConstrBigIntegerScaleMathContext_AndroidFailure() { 
        MathContext mc;
        BigDecimal bd;
 
        mc = new MathContext(17, RoundingMode.FLOOR);
        bd = new BigDecimal(new BigInteger("123456789012345678"), 3, mc);
        assertEquals("incorrect value", "123456789012345.67", bd.toString());
    } 
 
 
    /** 
     * new BigDecimal(char[] value, int offset, int len, MathContext mc); 
     */ 
    public void testConstrCharIntIntMathContext() { 
        char value[] = {'-', '1', '2', '3', '8', '0', '.', '4', '7', '3', '8', 'E', '-', '4', '2', '3'};
        int offset = 3;
        int len = 12;
        int precision = 4;
        RoundingMode rm = RoundingMode.CEILING;
        MathContext mc = new MathContext(precision, rm);