Commit f0fdd66b by Mark Wielaard Committed by Mark Wielaard

Double.java: More Classpath merging

	* 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()

From-SVN: r46370
parent afb649d5
2001-10-19 Mark Wielaard <mark@klomp.org> 2001-10-19 Mark Wielaard <mark@klomp.org>
* 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()
2001-10-19 Mark Wielaard <mark@klomp.org>
* javax/naming/BinaryRefAddr.java: New file * javax/naming/BinaryRefAddr.java: New file
* javax/naming/InitialContext.java: Compile fix * javax/naming/InitialContext.java: Compile fix
* javax/naming/InvalidNameException.java: Add comments * javax/naming/InvalidNameException.java: Add comments
......
...@@ -146,6 +146,14 @@ public final class Double extends Number implements Comparable ...@@ -146,6 +146,14 @@ public final class Double extends Number implements Comparable
* <code>instanceof</code> <code>Double</code>, and represents * <code>instanceof</code> <code>Double</code>, and represents
* the same primitive <code>double</code> value return * the same primitive <code>double</code> value return
* <code>true</code>. Otherwise <code>false</code> is returned. * <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.0d == -0.0d</code> returns <code>true</code>
* but <code>new Double(0.0d).equals(new Double(-0.0d))</code> returns
* <code>false</code>. And <code>Double.NaN == Double.NaN</code> returns
* <code>false</code>, but
* <code>new Double(Double.NaN).equals(new Double(Double.NaN))</code> returns
* <code>true</code>.
* *
* @param obj the object to compare to * @param obj the object to compare to
* @return whether the objects are semantically equal. * @return whether the objects are semantically equal.
...@@ -248,11 +256,9 @@ public final class Double extends Number implements Comparable ...@@ -248,11 +256,9 @@ public final class Double extends Number implements Comparable
*/ */
public static boolean isNaN (double v) public static boolean isNaN (double v)
{ {
long bits = doubleToLongBits (v); // This works since NaN != NaN is the only reflexive inequality
long e = bits & 0x7ff0000000000000L; // comparison which returns true.
long f = bits & 0x000fffffffffffffL; return v != v;
return e == 0x7ff0000000000000L && f != 0L;
} }
/** /**
...@@ -277,10 +283,7 @@ public final class Double extends Number implements Comparable ...@@ -277,10 +283,7 @@ public final class Double extends Number implements Comparable
*/ */
public static boolean isInfinite (double v) public static boolean isInfinite (double v)
{ {
long bits = doubleToLongBits (v); return (v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY);
long f = bits & 0x7fffffffffffffffL;
return f == 0x7ff0000000000000L;
} }
/** /**
...@@ -508,5 +511,5 @@ public final class Double extends Number implements Comparable ...@@ -508,5 +511,5 @@ public final class Double extends Number implements Comparable
* Initialize JNI cache. This method is called only by the * Initialize JNI cache. This method is called only by the
* static initializer when using JNI. * static initializer when using JNI.
*/ */
private static void initIDs () { /* Not used in libgcj */ }; private static native void initIDs ();
} }
...@@ -215,6 +215,14 @@ public final class Float extends Number implements Comparable ...@@ -215,6 +215,14 @@ public final class Float extends Number implements Comparable
* <code>instanceof</code> <code>Float</code>, and represents * <code>instanceof</code> <code>Float</code>, and represents
* the same primitive <code>float</code> value return * the same primitive <code>float</code> value return
* <code>true</code>. Otherwise <code>false</code> is returned. * <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 * @param obj the object to compare to
* @return whether the objects are semantically equal. * @return whether the objects are semantically equal.
...@@ -364,11 +372,9 @@ public final class Float extends Number implements Comparable ...@@ -364,11 +372,9 @@ public final class Float extends Number implements Comparable
*/ */
public static boolean isNaN (float v) public static boolean isNaN (float v)
{ {
int bits = floatToIntBits (v); // This works since NaN != NaN is the only reflexive inequality
int e = bits & 0x7f800000; // comparison which returns true.
int f = bits & 0x007fffff; return v != v;
return e == 0x7f800000 && f != 0;
} }
/** /**
...@@ -393,10 +399,7 @@ public final class Float extends Number implements Comparable ...@@ -393,10 +399,7 @@ public final class Float extends Number implements Comparable
*/ */
public static boolean isInfinite (float v) public static boolean isInfinite (float v)
{ {
int bits = floatToIntBits (v); return (v == POSITIVE_INFINITY || v == NEGATIVE_INFINITY);
int f = bits & 0x7fffffff;
return f == 0x7f800000;
} }
/** /**
......
...@@ -186,3 +186,9 @@ java::lang::Double::parseDouble(jstring str) ...@@ -186,3 +186,9 @@ java::lang::Double::parseDouble(jstring str)
} }
throw new NumberFormatException; throw new NumberFormatException;
} }
void
java::lang::Double::initIDs()
{
// Not used in libgcj
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment