JDK-8300869 : Make use of the Double.toString(double) algorithm in java.util.Formatter
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 19,20
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2023-01-23
  • Updated: 2025-07-16
  • Resolved: 2023-02-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21
21 b09Fixed
Related Reports
CSR :  
Relates :  
Sub Tasks
JDK-8301383 :  
Description
Methods `Double.toString(double)` and `AbstractStringBuilder.append(double)` make use of an algorithm integrated in JDK 19 [1], replacing the one used in earlier release; similarly for the `float` counterparts `Float.toString(float)` and `AbstractStringBuilder.append(float)`.

Class `java.util.Formatter`, however, uses another algorithm to format `double` and `float` values. This can lead to small discrepancies w.r.t. the outcomes of the above methods in certain rare cases, and conflicts with the specification which is based on `Double.toString(double)`. Therefore, to match the specification, `java.util.Formatter` should replace the current algorithm with a variant of the new one tailored for formatted output.

----

[1] https://git.openjdk.java.net/jdk/commit/72bcf2aa03d53b0f68eb07a902575b4e8628d859
Comments
Changeset: f696785f Author: Raffaello Giulietti <rgiulietti@openjdk.org> Date: 2023-02-02 19:10:42 +0000 URL: https://git.openjdk.org/jdk/commit/f696785fd3bc5b27c06260088a2e0ce520e12142
02-02-2023

Right, thanks [~rriggs]. My plan is to add some specific tests for differences in output I am aware of.
27-01-2023

If there may be differences in output, this issue may deserve a release note. If so, add label 'release-note=yes'.
27-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/12259 Date: 2023-01-27 16:02:38 +0000
27-01-2023