JDK-6285664 : [Fmt-Nu] Incorrect output with NumberFormat scientific notation
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2005-06-14
  • Updated: 2011-02-16
  • Resolved: 2005-09-12
Related Reports
Duplicate :  
Relates :  
Description
The following was found as part of RFE 4092330.  It is not really related to RFE 4092330 and therefore I am creating this bug for it.

DecimalFormat: A pattern like "##0.000E0" does not produce three fraction digits if the fraction part is close or equal to zero.

I ran the following code below using with 1.6.0 b40 on Solaris 9 and the bug still exists.

Compile and run the code below to see this bug:
---------- BEGIN SOURCE ----------
import java.text.DecimalFormat;

public class DecimalFormatTest {

   public static void main(String[] args) {

      DecimalFormat df = new DecimalFormat("##0.000E0"); // three fraction digits !
      System.out.println(df.format(12345.0)); // "12.345E3", OK
      System.out.println(df.format(12000.0)); // "12.00E3", BUG
      System.out.println(df.format(12001.0)); // "12.001E3", OK
      System.out.println(df.format(12000.3)); // "12.0003E3", BUG
      System.out.println(df.format(12000.7)); // "12.0007E3", BUG
      System.out.println(df.format(12000.03)); // "12.00E3", BUG
   }
}
---------- END SOURCE ----------

###@###.### 2005-06-14 23:34:31 GMT

Comments
EVALUATION Close this as a duplicate of 4871921. It will be fixed in Dolphin.
12-09-2005