static boolean m(double v) {
return(v != v == Double.isNaN(v));
// when d1 = Double.Nan
// When the method invokes
// (Nan != Nan == Nan)
// How is this true?
// when d2 = Double.POSITIVE_INFINITY
// (Infinity != Infinity == Infinity)
// How is this true? am I missing any evaluation
// order? Is there any chart for false == false = true
// something like that?
}
public static void main (
String args[]) {
double d1 = Double.NaN;
System.out.println(d1); // Printing Nan
double d2 = Double.POSITIVE_INFINITY;
System.out.println(d2); // Printing Infinity
double d3 = Double.MAX_VALUE;
System.out.println(d3); // Printing 1.767E3
System.out.print(m(d1) + "," + m(d2) + "," + m(d3));
}
Output is true,true,true. How ?