This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: floatToRawIntBits, doubleToRawLongBits, + cleanups.


Tom Tromey wrote:

> There are multiple NaN representations.  doubleToLongBits always
> returns a fixed value for any NaN, but doubleToRawLongBits returns the
> actual NaN value.

OIC. Thanks! Here's the correct patch, which I'll check in once my build
completes.

regards

  [ bryce ]

2001-02-09  Bryce McKinlay  <bryce@albatross.co.nz>

	* java/lang/Double.java (doubleToRawLongBits): Now native.
	* java/lang/Float.java (floatToRawIntBits): Likewise.
	* java/lang/natDouble.cc (doubleToRawLongBits): New method.
	* java/lang/natFloat.cc (floatToRawIntBits): Likewise.

Index: Double.java
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/lang/Double.java,v
retrieving revision 1.8
diff -u -r1.8 Double.java
--- Double.java	2001/02/09 02:56:38	1.8
+++ Double.java	2001/02/09 21:25:32
@@ -138,13 +138,7 @@
   }
 
   public static native long doubleToLongBits (double value);
-
-  public static long doubleToRawLongBits (double value)
-  {
-    // FIXME: Check that this is correct with respect to NaN values.
-    return doubleToLongBits (value);
-  }
-
+  public static native long doubleToRawLongBits (double value);
   public static native double longBitsToDouble (long bits);
 
   public int compareTo (Double d)
Index: Float.java
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/lang/Float.java,v
retrieving revision 1.7
diff -u -r1.7 Float.java
--- Float.java	2001/02/09 02:56:38	1.7
+++ Float.java	2001/02/09 21:25:32
@@ -145,14 +145,7 @@
   }
 
   public static native int floatToIntBits (float value);
-  
-  public static int floatToRawIntBits (float value)
-  {
-    // FIXME: Is this supposed to be different? NaN values seem to be handled
-    // the same in the JDK.
-    return floatToIntBits (value);
-  }
-
+  public static native int floatToRawIntBits (float value);
   public static native float intBitsToFloat (int bits);
 
   public int compareTo (Float d)
Index: natDouble.cc
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/lang/natDouble.cc,v
retrieving revision 1.10
diff -u -r1.10 natDouble.cc
--- natDouble.cc	2000/12/04 08:22:34	1.10
+++ natDouble.cc	2001/02/09 21:25:32
@@ -1,6 +1,6 @@
 // natDouble.cc - Implementation of java.lang.Double native methods.
 
-/* Copyright (C) 1998, 1999, 2000  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -45,6 +45,14 @@
   if (e == 0x7ff0000000000000LL && f != 0L)
     u.l = 0x7ff8000000000000LL;
 
+  return u.l;
+}
+
+jlong 
+java::lang::Double::doubleToRawLongBits(jdouble value)
+{
+  union u u;
+  u.d = value;
   return u.l;
 }
 
Index: natFloat.cc
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/lang/natFloat.cc,v
retrieving revision 1.4
diff -u -r1.4 natFloat.cc
--- natFloat.cc	2000/03/07 19:55:26	1.4
+++ natFloat.cc	2001/02/09 21:25:32
@@ -1,6 +1,6 @@
 // natFloat.cc - Implementation of java.lang.Float native methods.
 
-/* Copyright (C) 1998, 1999  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2001  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -30,6 +30,14 @@
   if (e == 0x7f800000 && f != 0)
     u.l = 0x7fc00000;
 
+  return u.l;
+}
+
+jint 
+java::lang::Float::floatToRawIntBits(jfloat value)
+{
+  union u u;
+  u.d = value;  
   return u.l;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]