Code example for BigDecimal

Methods: movePointRight, scale, toString

0
import junit.framework.TestCase; 
 
public class OldBigDecimalScaleOperationsTest extends TestCase {
 
    public void testMovePointRightEx() { 
        BigDecimal a = new BigDecimal("12345.6789012345678901234567890123456789");
        BigDecimal res = a.movePointRight(10);
        assertEquals("incorrect scale", 24, res.scale());
        assertEquals("incorrect value", "123456789012345.678901234567890123456789", res.toString());
        res = a.movePointRight(-50);
        assertEquals("incorrect scale", 84, res.scale());
        assertEquals("incorrect value", "1.23456789012345678901234567890123456789E-46", res.toString());
        try { 
            a.movePointRight(Integer.MIN_VALUE + 2);
            fail("ArithmeticException is not thrown");
        } catch (ArithmeticException expected) {
        } 
    } 
 
    // Throws OutOfMemoryError instead of ArithmeticException! 
    public void testMovePointRightEx2() {