Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6285664

[Fmt-Nu] Incorrect output with NumberFormat scientific notation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 6
    • core-libs
    • None
    • generic
    • generic

      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

            peytoia Yuka Kamiya (Inactive)
            sjchan Steven Chan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: