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


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