Code example for MathContext

0
            fail("No ArithmeticException for RoundingMode.UNNECESSARY");
        } catch (ArithmeticException e) {
            // expected 
        } 
 
        mc = new MathContext(7, RoundingMode.FLOOR);
        bd = new BigDecimal("1000000.9", mc);
        assertEquals("incorrect value", "1000000", bd.toString());
    } 
 
// ANDROID ADDED 
 
    /** 
     * java.math.BigDecimal#BigDecimal(java.math.BigInteger, int) 
     */ 
    public void test_Constructor_java_math_BigInteger_int() { 
        BigInteger value = new BigInteger("12345908");
        BigDecimal big = new BigDecimal(value);
        assertTrue("the BigDecimal value is not initialized properly",
                big.unscaledValue().equals(value)
                && big.scale() == 0);