Date: Mon, 30 Aug 2004 21:09:22 -0500 From: "Thomas M. Hermann" <Thomas.Hermann@cox.net> To: freebsd-java@FreeBSD.org Subject: Math.pow(a,b) Bug Message-ID: <1093918161.34617.17.camel@daedalus.542.wifi.net>
index | next in thread | raw e-mail
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
---------------------------------
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1093918161.34617.17.camel>
