1 |
/* Double.java -- object wrapper for double primitive |
/* Double.java -- object wrapper for double primitive |
2 |
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
44 |
* |
* |
45 |
* @author Paul Fisher |
* @author Paul Fisher |
46 |
* @author Andrew Haley <aph@cygnus.com> |
* @author Andrew Haley <aph@cygnus.com> |
47 |
* @since JDK 1.0 |
* @author Eric Blake <ebb9@email.byu.edu> |
48 |
|
* @since 1.0 |
49 |
*/ |
*/ |
50 |
public final class Double extends Number implements Comparable |
public final class Double extends Number implements Comparable |
51 |
{ |
{ |
164 |
if (!(obj instanceof Double)) |
if (!(obj instanceof Double)) |
165 |
return false; |
return false; |
166 |
|
|
167 |
Double d = (Double) obj; |
double d = ((Double) obj).value; |
168 |
|
|
169 |
return doubleToLongBits (value) == doubleToLongBits (d.doubleValue ()); |
// common case first, then check NaN and 0 |
170 |
|
if (value == d) |
171 |
|
return (value != 0) || (1 / value == 1 / d); |
172 |
|
return isNaN(value) && isNaN(d); |
173 |
} |
} |
174 |
|
|
175 |
/** |
/** |
340 |
return isNaN (y) ? 0 : 1; |
return isNaN (y) ? 0 : 1; |
341 |
if (isNaN (y)) |
if (isNaN (y)) |
342 |
return -1; |
return -1; |
343 |
if (x == 0.0d && y == -0.0d) |
// recall that 0.0 == -0.0, so we convert to infinites and try again |
344 |
return 1; |
if (x == 0 && y == 0) |
345 |
if (x == -0.0d && y == 0.0d) |
return (int) (1 / x - 1 / y); |
|
return -1; |
|
346 |
if (x == y) |
if (x == y) |
347 |
return 0; |
return 0; |
348 |
|
|