Code example for BigDecimal

Methods: compareToprecisionsetScale

0
    /** 
     * check that setScale with a scale greater to the existing scale does not 
     * change the value. 
     */ 
    public void testSetScale() { 
        BigDecimal x1 = new BigDecimal(1.23400);
        BigDecimal x2 = x1.setScale(75);
 
        assertEquals(0, x1.compareTo(x2));
        assertEquals(0, x2.compareTo(x1));
 
        x1.precision();
 
        assertEquals(0, x1.compareTo(x2));
        assertEquals(0, x2.compareTo(x1));
 
        x2.precision();
 
        assertEquals(0, x1.compareTo(x2));
        assertEquals(0, x2.compareTo(x1));
    } 
} 
Experience pair programming with AI  Get Codota for Java