Release Note: `java.util.Formatter` May Return Slightly Different Results on `double` and `float`

XMLWordPrintable

    • Type: Sub-task
    • Resolution: Delivered
    • Priority: P4
    • 21
    • Affects Version/s: 21
    • Component/s: core-libs
    • In Review
    • generic
    • generic

      The implementation of `java.util.Formatter` for `double` and `float` conversions to decimal (`'e'`, `'E'`, `'f'`, `'g'`, `'G'`) is now aligned with the one in `Double.toString(double)`, which was changed in JDK 19.

      As a consequence, in some rare circumstances, the outcomes may slightly differ from the ones in earlier releases.

      One example is with `double` `2e23` and format `"%.16e"`. With this change, the outcome is `2.0000000000000000e+23`, while earlier releases produce `1.9999999999999998e+23`. Any smaller precision in the format (e.g., "%.15e") on this value will produce outcomes that are equal to each other, though.

      Another example is with `double` `9.9e-324` and format `"%.2g"`. The new outcome is `9.9e-324`, but earlier releases generate `"1.0e-323"`.

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

              Created:
              Updated:
              Resolved: