JDK-8369050 : DecimalFormat Rounding Errors for Fractional Ties Near Zero
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 25
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2025-10-01
  • Updated: 2025-12-01
  • Resolved: 2025-10-10
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 25 JDK 26
25.0.3Fixed 26 b20Fixed
Related Reports
Relates :  
Description
java.text.DecimalFormat::setRoundingMode does not round input as specified by the rounding mode.
Regression: Last worked in version 21.0.8.

Sample :
import java.math.RoundingMode;
import java.text.DecimalFormat;

public class DecimalFormatExample {
    public static void main(String[] args) {
        DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
        format.setMaximumFractionDigits(10);
        format.setRoundingMode(RoundingMode.HALF_UP);
        var expected = "0.0000000001";
        var actual = format.format(Double.parseDouble("0.00000000005"));
        if (!expected.equals(actual)) {
            throw new AssertionError("Expected: " + expected + ", Actual: " + actual);
        }
    }
}

This bug happens on tie cases when DecimalFormat rounds a fractional double whose least significant digit is one index past the maximum fraction digits allowed by the format.

Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk25u-dev/pull/4 Date: 2025-11-25 21:06:36 +0000
26-11-2025

[jdk25u-fix-request] Approval Request from Roland Mesde for backport of JDK-8369050: DecimalFormat Rounding Errors for Fractional Ties Near Zero.
26-11-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk25u/pull/371 Date: 2025-11-10 21:07:14 +0000
25-11-2025

Changeset: 376d77e8 Branch: master Author: Justin Lu <jlu@openjdk.org> Date: 2025-10-10 16:27:56 +0000 URL: https://git.openjdk.org/jdk/commit/376d77e8a71478f456af5baaf47f446eebd79e36
10-10-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/27681 Date: 2025-10-07 23:19:28 +0000
07-10-2025