This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: Float/Double partial merge
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 15 Jan 2002 21:17:15 -0700
- Subject: Patch: FYI: Float/Double partial merge
- Reply-to: tromey at redhat dot com
I'm checking this in.
This partially (re-)merges Float and Double with Classpath. I've
elected to keep a couple methods as-is. I suspect we'll do better
with these as they are.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/lang/Float.java (equals): Preserve old code.
* java/lang/Double.java (equals): Preserve old code.
2002-01-15 Eric Blake <ebb9@email.byu.edu>
* java/lang/Double.java (equals, compare): Fix 0.0 vs. -0.0 math.
* java/lang/Float.java (equals, compare): Ditto.
Index: java/lang/Double.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Double.java,v
retrieving revision 1.13
diff -u -r1.13 Double.java
--- java/lang/Double.java 2001/11/14 19:11:52 1.13
+++ java/lang/Double.java 2002/01/16 03:59:11
@@ -1,5 +1,5 @@
/* Double.java -- object wrapper for double primitive
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -163,9 +163,12 @@
if (!(obj instanceof Double))
return false;
- Double d = (Double) obj;
+ double d = ((Double) obj).value;
- return doubleToLongBits (value) == doubleToLongBits (d.doubleValue ());
+ // GCJ LOCAL: this implementation is probably faster than
+ // Classpath's, especially once we inline doubleToLongBits.
+ return doubleToLongBits (value) == doubleToLongBits (d);
+ // END GCJ LOCAL
}
/**
@@ -334,10 +337,9 @@
return isNaN (y) ? 0 : 1;
if (isNaN (y))
return -1;
- if (x == 0.0d && y == -0.0d)
- return 1;
- if (x == -0.0d && y == 0.0d)
- return -1;
+ // recall that 0.0 == -0.0, so we convert to infinites and try again
+ if (x == 0 && y == 0)
+ return (int) (1 / x - 1 / y);
if (x == y)
return 0;
Index: java/lang/Float.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Float.java,v
retrieving revision 1.11
diff -u -r1.11 Float.java
--- java/lang/Float.java 2001/10/26 01:51:04 1.11
+++ java/lang/Float.java 2002/01/16 03:59:11
@@ -1,5 +1,5 @@
/* java.lang.Float
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -232,9 +232,12 @@
if (!(obj instanceof Float))
return false;
- Float f = (Float) obj;
+ float f = ((Float) obj).value;
- return floatToIntBits (value) == floatToIntBits (f.floatValue ());
+ // GCJ LOCAL: this implementation is probably faster than
+ // Classpath's, especially once we inline floatToIntBits.
+ return floatToIntBits (value) == floatToIntBits (f);
+ // END GCJ LOCAL
}
/**
@@ -484,10 +487,9 @@
return isNaN (y) ? 0 : 1;
if (isNaN (y))
return -1;
- if (x == 0.0 && y == -0.0)
- return 1;
- if (x == -0.0 && y == 0.0)
- return -1;
+ // recall that 0.0 == -0.0, so we convert to infinities and try again
+ if (x == 0 && y == 0)
+ return (int) (1 / x - 1 / y);
if (x == y)
return 0;