Code example for BigDecimal

Methods: floatValue

0
    /** 
     * Float value of a negative BigDecimal 
     */ 
    public void testFloatValueNeg() { 
        String a = "-1238096483923847.6356789029578E+21";
        BigDecimal aNumber = new BigDecimal(a);
        float result = -1.2380965E36F;
        assertTrue("incorrect value", aNumber.floatValue() == result);
    } 
 
    /** 
     * Float value of a positive BigDecimal 
     */ 
    public void testFloatValuePos() { 
        String a = "1238096483923847.6356789029578E+21";
        BigDecimal aNumber = new BigDecimal(a);
        float result = 1.2380965E36F;
        assertTrue("incorrect value", aNumber.floatValue() == result);
    } 
 
    /**