Hi,

Brian Jones had merged java.lang.Double/Float a couple of months ago.
But there were still a couple of comment/indentation differences.
I reindented/reformatted and renamed a method variable here and there.
The actual code changes are minimal:

        * java/lang/Double.java: Partial merge with libgcj
        (serialVersionUID): new private field
        (byteValue): removed, already defined in superclass Number
        (shortValue): likewise
        * java/lang/Float.java: Partial merge with libgcj
        (serialVersionUID): new private field

There are still a few differences between the code and I did not look
at the native code at all. If my patch is accepted by the libgcj people
then the actual diff between the Classpath and libgcj version looks like
the attached diff. Maybe someone who knows a bit about float/doubles in
java can comment on these differences.

Cheers,

Mark
-- 
Stuff to read:
    <http://www.toad.com/gnu/whatswrong.html>
  What's Wrong with Copy Protection, by John Gilmore
--- java/lang/Double.java       Fri Oct 12 16:08:07 2001
+++ ../gcc-3-1/libjava/java/lang/Double.java    Fri Oct 12 16:10:50 2001
@@ -248,7 +248,11 @@
    */
   public static boolean isNaN (double v)
   {
-    return (doubleToLongBits (v) == 0x7ff8000000000000L);
+    long bits = doubleToLongBits (v);
+    long e = bits & 0x7ff0000000000000L;
+    long f = bits & 0x000fffffffffffffL;
+
+    return e == 0x7ff0000000000000L && f != 0L;
   }
 
   /**
@@ -273,7 +277,10 @@
    */
   public static boolean isInfinite (double v)
   {
-    return (v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY);
+    long bits = doubleToLongBits (v);
+    long f = bits & 0x7fffffffffffffffL;
+
+    return f == 0x7ff0000000000000L;
   }
 
   /**
@@ -494,18 +501,12 @@
    * @see #NEGATIVE_INFINITY
    * @since 1.2
    */
-  public static double parseDouble (String s) throws NumberFormatException
-  {
-    String t = s.trim ();
-      return parseDouble0 (t);
-  }
-
-  private static native double parseDouble0 (String s)
+  public native static double parseDouble (String s) 
     throws NumberFormatException;
 
   /**
    * Initialize JNI cache.  This method is called only by the 
    * static initializer when using JNI.
    */
-  private static native void initIDs ();
+  private static void initIDs () { /* Not used in libgcj */ };
 }
--- java/lang/Float.java        Fri Oct 12 14:37:56 2001
+++ ../gcc-3-1/libjava/java/lang/Float.java     Fri Oct 12 14:33:38 2001
@@ -221,7 +221,12 @@
    */
   public boolean equals (Object obj)
   {
-    return (obj instanceof Float && ((Float) obj).value == value);
+    if (!(obj instanceof Float))
+      return false;
+
+    Float f = (Float) obj;
+
+    return floatToIntBits (value) == floatToIntBits (f.floatValue ());
   }
 
   /**
@@ -359,7 +364,11 @@
    */
   public static boolean isNaN (float v)
   {
-    return (floatToIntBits (v) == 0x7fc00000);
+    int bits = floatToIntBits (v);
+    int e = bits & 0x7f800000;
+    int f = bits & 0x007fffff;
+
+    return e == 0x7f800000 && f != 0;
   }
 
   /**
@@ -384,7 +393,10 @@
    */
   public static boolean isInfinite (float v)
   {
-    return (v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY);
+    int bits = floatToIntBits (v);
+    int f = bits & 0x7fffffff;
+
+    return f == 0x7f800000;
   }
 
   /**

Reply via email to