Name: nt126004 Date: 05/30/2003
FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
FULL OS VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
A DecimalFormat with the pattern "##0.##E0" does not give the expected number of significant digits when formatting the value 12345. This pattern and value are those used in the API documentation. The expected result is given there as "12.3E3", while the actual result is "12.345E3". The same result occurs with JDKs 1.3.1 and 1.4.1 so the discrepancy is not new.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached code and compare the result with the API documentation!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
12.3E3
123E3
1.23E6
ACTUAL -
12.345E3
123.46E3
1.2346E6
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.text.DecimalFormat;
class TestDecimalFormat
{
public static void main(String[] args)
{
DecimalFormat f = new DecimalFormat("##0.##E0");
try
{
System.out.println(f.format(12345));
System.out.println(f.format(123456));
System.out.println(f.format(1234567));
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
(Review ID: 186640)
======================================================================