JDK-4939441 : log1p fails on NaN arguments
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-10-17
  • Updated: 2004-03-29
  • Resolved: 2003-11-11
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 b28Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description

Name: vpR10072			Date: 10/17/2003



JDK            : JDK1.5.0-b23, JDK1.5.0-b24
JCK            : JCK1.5-runtime (b07)
Platform       : Windows
			r004: WinXP_Professional
			r006: Win2003Server
			r007: WinXP
			r010: Win98
Failing tests: 
	api/java_lang/Math/index.html#log1p[log1p0001] 
	api/java_lang/StrictMath/index.html#log1p[log1p0001]

This log1p0001 test fails on Windows platforms only.

Corresponding index_log1p.jtr files have the following line:
	log1p0001: Failed. Unexpected result for NaN

The log1p spec states:
	If the argument is NaN or less than -1, then the result is NaN

The log1p0001 testcase tries to call the log1p(double x) method with some
different representations of NaN (according to IEEE-754)
double floating point values as argument and checks that the result is NaN.
However, -Infinity is returned for some NaN values.

How to reproduce:
=================

Here is a small testcase:
----------------------------------------------- bug.java
class bug {
    public static void main (String args[]) {
        double [] valArr = {Double.NaN,
                        Double.longBitsToDouble(0x7FF0000000000001L),
                        Double.longBitsToDouble(0xFFF0000000000001L),
                        Double.longBitsToDouble(0x7FF8555555555555L),
                        Double.longBitsToDouble(0xFFF8555555555555L),
                        Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),
                        Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),
                        Double.NEGATIVE_INFINITY,
                        -1000.0, -100.0, -10.0, -2.0, -1.5,
                        Double.longBitsToDouble(0xbff0000000000001L)
        };
 
        for (int i = 0; i < valArr.length; i++) {
            if (Double.compare(Double.NaN, StrictMath.log1p(valArr[i])) != 0) {
                System.out.println("Unexpected result for " + valArr[i]
                    + " (" + Long.toHexString(Double.doubleToRawLongBits(valArr[i]))
                    + ") got " + StrictMath.log1p(valArr[i])
                    + " [index=" + i + "]" );
            }
        }
    }
}
----------------------------------------------- bug.java

Test output:
============

$ java -showversion bug
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b23)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b23, mixed mode)

Unexpected result for NaN (fff8000000000001) got -Infinity [index=2]
Unexpected result for NaN (fff8555555555555) got -Infinity [index=4]
Unexpected result for NaN (ffffffffffffffff) got -Infinity [index=6]


======================================================================

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

SUGGESTED FIX src/share/native/java/lang/fdlibm/src>sccs sccsdiff -r1.8 -r1.9 s_log1p.c ------- s_log1p.c ------- 111,112c111,118 < if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */ < else return (x-x)/(x-x); /* log1p(x<-1)=NaN */ --- > /* > * Added redundant test against hx to work around VC++ > * code generation problem. > */ > if(x==-1.0 && (hx==0xbff00000)) /* log1p(-1)=-inf */ > return -two54/zero; > else > return (x-x)/(x-x); /* log1p(x<-1)=NaN */ ###@###.### 2003-10-29
29-10-2003

EVALUATION Possible bug in fdlibm. ###@###.### 2003-10-17 Initial investigation casts suspicion on the Windows C++ compiler rather than a bug in the fdlibm source. The linux x86 jdk does not exhibit this problem. ###@###.### 2003-10-17
17-10-2003