From 2b37afcb360a9e4bff48fd71b1a5725c90515049 Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Wed, 14 Apr 1999 07:10:22 +0000 Subject: [PATCH] natDouble.java (doubleToLongBits): ensure that all NaNs are always converted to the same long value. 1999-04-14 Andrew Haley * java/lang/natDouble.java (doubleToLongBits): ensure that all NaNs are always converted to the same long value. * java/lang/natFloat.java (floatToIntBits): ditto, but for float converted to int. From-SVN: r26439 --- libjava/ChangeLog | 7 +++++++ libjava/java/lang/natDouble.cc | 7 +++++++ libjava/java/lang/natFloat.cc | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 1cd361cafe4..3d5b9ad1e60 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +1999-04-14 Andrew Haley + + * java/lang/natDouble.java (doubleToLongBits): ensure that all + NaNs are always converted to the same long value. + * java/lang/natFloat.java (floatToIntBits): ditto, but for float + converted to int. + 1999-04-13 Tom Tromey * java/lang/natSystem.cc (arraycopy): Don't always use jbyteArray; diff --git a/libjava/java/lang/natDouble.cc b/libjava/java/lang/natDouble.cc index 17990884751..8d8c7883ba4 100644 --- a/libjava/java/lang/natDouble.cc +++ b/libjava/java/lang/natDouble.cc @@ -47,6 +47,13 @@ java::lang::Double::doubleToLongBits(jdouble value) { union u u; u.d = value; + + jlong e = u.l & 0x7ff0000000000000LL; + jlong f = u.l & 0x000fffffffffffffLL; + + if (e == 0x7ff0000000000000LL && f != 0L) + u.l = 0x7ff8000000000000LL; + return u.l; } diff --git a/libjava/java/lang/natFloat.cc b/libjava/java/lang/natFloat.cc index e3189bebc2d..5712fd4190c 100644 --- a/libjava/java/lang/natFloat.cc +++ b/libjava/java/lang/natFloat.cc @@ -24,6 +24,12 @@ java::lang::Float::floatToIntBits(jfloat value) { union u u; u.d = value; + jint e = u.l & 0x7f800000; + jint f = u.l & 0x007fffff; + + if (e == 0x7f800000 && f != 0) + u.l = 0x7fc00000; + return u.l; }