Java Reference
In-Depth Information
example, this program prints
false
:
class Test {
public static void main(String[] args) {
double i = 0.0 / 0.0;
System.out.println(i - i == 0);
}
}
The principle underlying the rules for computing with NaN is that
once it generates NaN, a
computation is damaged, and no further computation can repair the damage.
The NaN value is
intended to allow a damaged computation to proceed to a point where it is convenient to deal with
the situation.
In summary, the
float
and
double
types have a special NaN value to represent a quantity that is not
a number. The rules for computations involving NaN are simple and sensible, but the consequences
of these rules can be counterintuitive.
< Day Day Up >
Search WWH ::
Custom Search