public class Program {
public static void main(String[] args) {
double value = Math.sqrt(-1); // Produces NaN
if (Double.isNaN(value)) {
System.out.println("The value is NaN.");
} else {
System.out.println("The value is not NaN.");
}
}
}
/*
run:
The value is NaN.
*/