Code example for BigDecimal

Methods: toPlainString

0
     * Convert a negative BigDecimal with a negative exponent to a plain string 
     * representation; scale == 0. 
     */ 
     public void testToPlainStringNegNegExp() { 
        String a = "-123809648392384754573567356745735.63567890295784902768787678287E-100";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "-0.000000000000000000000000000000000000000000000000000000000000000000012380964839238475457356735674573563567890295784902768787678287";
        assertTrue("incorrect value", aNumber.toPlainString().equals(result));
    } 
 
    /** 
     * Convert a negative BigDecimal with a positive exponent 
     * to a plain string representation; 
     * scale == 0. 
     */ 
     public void testToPlainStringNegPosExp() { 
        String a = "-123809648392384754573567356745735.63567890295784902768787678287E100";
        BigDecimal aNumber = new BigDecimal(a);
        String result = "-1238096483923847545735673567457356356789029578490276878767828700000000000000000000000000000000000000000000000000000000000000000000000";
        assertTrue("incorrect value", aNumber.toPlainString().equals(result));