Code example for DecimalFormat

Methods: format, setGroupingUsed, setMaximumFractionDigits

0
    } 
 
    public void test_formatD() { 
        DecimalFormat format = (DecimalFormat) NumberFormat
                .getInstance(Locale.ENGLISH);
        format.setGroupingUsed(false);
        format.setMaximumFractionDigits(400);
        assertEquals("123456789012345", format.format(123456789012345.));
        assertEquals("1", "12345678901234.5", format.format(12345678901234.5));
        assertEquals("2", "1234567890123.25", format.format(1234567890123.25));
        assertEquals("3", "999999999999.375", format.format(999999999999.375));
        assertEquals("4", "99999999999.0625", format.format(99999999999.0625));
        assertEquals("5", "9999999999.03125", format.format(9999999999.03125));
        assertEquals("6", "999999999.015625", format.format(999999999.015625));
        assertEquals("7", "99999999.0078125", format.format(99999999.0078125));
        assertEquals("8", "9999999.00390625", format.format(9999999.00390625));
        assertEquals("9", "999999.001953125", format.format(999999.001953125));
        assertEquals("10", "9999.00048828125", format.format(9999.00048828125));
        assertEquals("11", "999.000244140625", format.format(999.000244140625));
        assertEquals("12", "99.0001220703125", format.format(99.0001220703125));
        assertEquals("13", "9.00006103515625", format.format(9.00006103515625));
        assertEquals("14", "0.000030517578125", format.format(0.000030517578125));
    } 
 
 
    public void test_getNegativePrefix() { 
        DecimalFormat df = new DecimalFormat();