import java.lang.Math; public class testNaN { public static void main(String[] args) { double x, y, z; x = 0.0; y = 0.0; z = x/y; // generate a NaN System.out.println("This line should read: 0.0/0.0 -> NaN"); System.out.println(x + "/" + y + " -> " + z); if (z == z) System.out.println("Incorrect comparison of NaNs with =="); if (z != z) System.out.println("Correct comparison of NaNs with !="); if (!Double.isNaN(z)) System.out.println("Incorrect test of NaN with isNaN()"); if (Double.isNaN(z)) System.out.println("Correct test of NaN with isNaN()"); } }