Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4511638 Double.toString(double) sometimes produces incorrect results
  3. JDK-8291475

Release Note: Double.toString(double) and Float.toString(float) may Return Slightly Different Results

XMLWordPrintable

    • Fix Understood
    • generic
    • generic

      The specification of these methods is now tighter than in earlier releases and the new implementation fully adheres to it.

      As a consequence, some returned strings are now shorter than when using earlier releases, and for inputs at the extremes of the subnormal ranges near zero, might look differently. However, the number of cases where there's a difference in output is quite small compared to the sheer number of possible `double` and `float` inputs.

      One example is `Double.toString(2e23)`, which now returns `"2.0E23"`, whereas in earlier releases it returns `"1.9999999999999998E23"`.
      Another example, in the `double` subnormal range, is `Double.toString(1e-323)` which now returns `"9.9E-324"`, as mandated by the new specification.

            rgiulietti Raffaello Giulietti
            rgiulietti Raffaello Giulietti
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: