From owner-freebsd-java@FreeBSD.ORG Tue Aug 31 02:08:05 2004 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7160016A4CE for ; Tue, 31 Aug 2004 02:08:05 +0000 (GMT) Received: from lakermmtao12.cox.net (lakermmtao12.cox.net [68.230.240.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id E7DE843D45 for ; Tue, 31 Aug 2004 02:08:04 +0000 (GMT) (envelope-from Thomas.Hermann@cox.net) Received: from [192.168.1.2] (really [68.102.112.132]) by lakermmtao12.cox.net (InterMail vM.6.01.03.02.01 201-2131-111-104-103-20040709) with ESMTP id <20040831020800.IZZN10626.lakermmtao12.cox.net@[192.168.1.2]> for ; Mon, 30 Aug 2004 22:08:00 -0400 From: "Thomas M. Hermann" To: freebsd-java@FreeBSD.org Content-Type: multipart/mixed; boundary="=-bch+Wpkq/6UBCHGw87bz" Message-Id: <1093918161.34617.17.camel@daedalus.542.wifi.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 30 Aug 2004 21:09:22 -0500 X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: Math.pow(a,b) Bug X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2004 02:08:05 -0000 --=-bch+Wpkq/6UBCHGw87bz Content-Type: text/plain Content-Transfer-Encoding: 7bit java.lang.Math.pow(a,b) incorrectly returns a positive value when a negative value is raise to an odd integer. This occurs with the jdk-1.4.2p6_4, which applies patchset 6. The attached file will demonstrate the error. The problem appears to be corrected by rebuilding the JVM with the following correction: --- e_pow.c.orig Mon Aug 30 21:01:45 2004 +++ e_pow.c Mon Aug 30 21:01:01 2004 @@ -173,7 +173,7 @@ } /* (x<0)**(non-int) is NaN */ - if(((((u_int32_t)hx>>31)+1)|yisint)==0) return (x-x)/(x-x); + if(((((int32_t)hx>>31)+1)|yisint)==0) return (x-x)/(x-x); /* |y| is huge */ if(iy>0x41e00000) { /* if |y| > 2**31 */ Furthermore, examining the experimental patchset, it appears that the following patch also corrects the error: 2004-07-08 Thursday 20:09 glewis * j2se/src/share/native/java/lang/fdlibm/src/e_pow.c: . Merge in a fix recently added to FreeBSD's math library (taken from fdlibm-5.3): "Fixed the sign of the result in some overflow and underflow cases (ones where the exponent is an odd integer and the base is negative)." I've not yet run this through the compatibility test suite, so this change may be backed out if the suite relies on the broken behaviour. If I had the compatibility test suite, I would be willing to apply the experimental patchset and perform the test. At the moment, I am not willing to apply the patchset without being able to test the results. Please email me with any questions or suggestions. Best regards, Tom H. -- --------------------------------- -- Thomas M. Hermann -- Thomas.Hermann AT cox DOT net --------------------------------- --=-bch+Wpkq/6UBCHGw87bz--