Double.NaN Float.NaN
Double.NaN Float.NaN
double i = 0.0/0.0;
double i = Double.NaN;
double i = 0.0/0.0;
double i = Double.NaN;
equals
http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html
public boolean equals(Object obj)
Compares this object against the specified object. The result
is
true
if and only if the argument is not
null
and is a Double
object that
represents a double
that has the same value as the
double
represented by this object. For this
purpose, two double
values are considered to be
the same if and only if the method doubleToLongBits(double)
returns the identical
long
value when applied to each.
Note that in most cases, for two instances of class
Double
, d1
and d2
, the
value of d1.equals(d2)
is true
if and
only if
d1.doubleValue() == d2.doubleValue()
also has the value true
. However, there are two
exceptions:
- If
d1
andd2
both representDouble.NaN
, then theequals
method returnstrue
, even thoughDouble.NaN==Double.NaN
has the valuefalse
. - If
d1
represents+0.0
whiled2
represents-0.0
, or vice versa, theequal
test has the valuefalse
, even though+0.0==-0.0
has the valuetrue
.
评论
发表评论