diff options
author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-10-20 06:26:45 +0000 |
---|---|---|
committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-10-20 06:26:45 +0000 |
commit | a18ceed4ecab75d62a7980611f780c3086759976 (patch) | |
tree | a4ea1a7426a312774f365dbcd1470afc8f6da6ed /libjava/java/lang/Float.java | |
parent | 3de15244c5256aa010ffece50f3c80e86f3cad49 (diff) | |
download | ppe42-gcc-a18ceed4ecab75d62a7980611f780c3086759976.tar.gz ppe42-gcc-a18ceed4ecab75d62a7980611f780c3086759976.zip |
* java/lang/Double.java: More Classpath merging
(isInfinite): Don't use doubleToLongBits
(isNaN (Object)): return v != v
(initIDs): make native
* java/lang/Float.java: Ditto
(isInfinite): Don't use floatToIntBits
(isNaN (Object)): return v != v
* java/lang/natDouble.cc: add empty initIDs()
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46370 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang/Float.java')
-rw-r--r-- | libjava/java/lang/Float.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/libjava/java/lang/Float.java b/libjava/java/lang/Float.java index 91da0754d60..9e26143f773 100644 --- a/libjava/java/lang/Float.java +++ b/libjava/java/lang/Float.java @@ -215,6 +215,14 @@ public final class Float extends Number implements Comparable * <code>instanceof</code> <code>Float</code>, and represents * the same primitive <code>float</code> value return * <code>true</code>. Otherwise <code>false</code> is returned. + * <p> + * Note that there are two differences between <code>==</code> and + * <code>equals()</code>. <code>0.0f == -0.0f</code> returns <code>true</code> + * but <code>new Float(0.0f).equals(new Float(-0.0f))</code> returns + * <code>false</code>. And <code>Float.NaN == Float.NaN</code> returns + * <code>false</code>, but + * <code>new Float(Float.NaN).equals(new Float(Float.NaN))</code> returns + * <code>true</code>. * * @param obj the object to compare to * @return whether the objects are semantically equal. @@ -364,11 +372,9 @@ public final class Float extends Number implements Comparable */ public static boolean isNaN (float v) { - int bits = floatToIntBits (v); - int e = bits & 0x7f800000; - int f = bits & 0x007fffff; - - return e == 0x7f800000 && f != 0; + // This works since NaN != NaN is the only reflexive inequality + // comparison which returns true. + return v != v; } /** @@ -393,10 +399,7 @@ public final class Float extends Number implements Comparable */ public static boolean isInfinite (float v) { - int bits = floatToIntBits (v); - int f = bits & 0x7fffffff; - - return f == 0x7f800000; + return (v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY); } /** |