Double.NaN == Double.NaN is false

This code segment:
if (Double.NaN == Double.NaN) {
System.out.print("True");
}
else {
System.out.println("False");
}

will print "False".
But IntelliJ warns about the expression being always true:
"Condition Double.NaN == Double.NaN is always true."
This is wrong.

0

What's the use of this code ?

BoD


Amir Eliaz wrote:

This code segment:
if (Double.NaN == Double.NaN) {
System.out.print("True");
}
else {
System.out.println("False");
}

will print "False".
But IntelliJ warns about the expression being always true:
"Condition Double.NaN == Double.NaN is always true."
This is wrong.

0

It's from a test I am giving to students :)

0

Right, it's a duplicate...

0

Mine was in first ;)

0

请先登录再写评论。