Code example for BigInteger

Methods: equals

0
 
    /** 
     * 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);
 
        BigInteger value2 = new BigInteger("12334560000");
        BigDecimal big2 = new BigDecimal(value2, 5);
        assertTrue("the BigDecimal value is not initialized properly",
                big2.unscaledValue().equals(value2)
                && big2.scale() == 5);
        assertTrue("the BigDecimal value is not represented properly", big2.toString().equals(
                "123345.60000")); 
    } 
 
Experience pair programming with AI  Get Codota for Java