1 |
/* java.lang.Float |
/* java.lang.Float |
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 Float extends Number implements Comparable |
public final class Float extends Number implements Comparable |
51 |
{ |
{ |
233 |
if (!(obj instanceof Float)) |
if (!(obj instanceof Float)) |
234 |
return false; |
return false; |
235 |
|
|
236 |
Float f = (Float) obj; |
float f = ((Float) obj).value; |
237 |
|
|
238 |
return floatToIntBits (value) == floatToIntBits (f.floatValue ()); |
// common case first, then check NaN and 0 |
239 |
|
if (value == f) |
240 |
|
return (value != 0) || (1 / value == 1 / f); |
241 |
|
return isNaN(value) && isNaN(f); |
242 |
} |
} |
243 |
|
|
244 |
/** |
/** |
488 |
return isNaN (y) ? 0 : 1; |
return isNaN (y) ? 0 : 1; |
489 |
if (isNaN (y)) |
if (isNaN (y)) |
490 |
return -1; |
return -1; |
491 |
if (x == 0.0 && y == -0.0) |
// recall that 0.0 == -0.0, so we convert to infinities and try again |
492 |
return 1; |
if (x == 0 && y == 0) |
493 |
if (x == -0.0 && y == 0.0) |
return (int) (1 / x - 1 / y); |
|
return -1; |
|
494 |
if (x == y) |
if (x == y) |
495 |
return 0; |
return 0; |
496 |
|
|