JDK-4831589 : Math.rint(double) returns incorrect results
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-03-12
  • Updated: 2003-06-21
  • Resolved: 2003-06-21
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.
Other
5.0 b07Fixed
Description

Name: rmT116609			Date: 03/12/2003


FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
For certain input values, Math.rint(double) returns results which are off by 1.  For example, the values 262144.75, 262146.75, 262148.75, ... 499998.75 are all rounded down instead of up.



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class RintBugCheck {

  public static void main(String[] args) {
    double test     = 300000.75;
    double expected = 300001.0;
    double actual   = Math.rint(test);
    if (actual != expected) {
      System.err.println("BUG: " + actual + " != " + expected);
    }
  }

}
---------- END SOURCE ----------
(Review ID: 182547) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger-b07
2004-06-14

SUGGESTED FIX Java rint implementation added to src/share/classes/java/lang/StrictMath.java New regression tests in test/java/lang/Math/Rint.java Concomitant build changes excising native rint made in src/share/native/java/lang/StrictMath.c src/share/native/java/lang/fdlibm/include/jfdlibm.h make/java/java/mapfile-vers
2004-06-11

EVALUATION Reproduced problem on Solaris SPARC. Something strange is happending; the problem does not seem to be due to faulty decimal <-> binary conversion, etc. ###@###.### 2003-03-13 JDC comments indicate bug is in fdlibm; will investigate to confirm. ###@###.### 2003-04-30 Bug in fdlibm confirmed -- reported to appropriate parties. ###@###.### 2003-05-09
2003-04-30