Code example for BigDecimal

Methods: abs

0
                assertEquals("stripTrailingZero failed for 0.0000", 4, zerotest.stripTrailingZeros().scale());
	}	 
 
	public void testMathContextConstruction() { 
        String a = "-12380945E+61";
        BigDecimal aNumber = new BigDecimal(a);
        int precision = 6;
        RoundingMode rm = RoundingMode.HALF_DOWN;
        MathContext mcIntRm = new MathContext(precision, rm);
        MathContext mcStr = new MathContext("precision=6 roundingMode=HALF_DOWN");
        MathContext mcInt = new MathContext(precision);
        BigDecimal res = aNumber.abs(mcInt);
        assertEquals("MathContext Constructer with int precision failed",
                res, 
                new BigDecimal("1.23809E+68"));
         
        assertEquals("Equal MathContexts are not Equal ",
                mcIntRm,
                mcStr);
         
        assertEquals("Different MathContext are reported as Equal ",