Back to Intellij Community

ComparisonToNaN

java/java-impl/resources/inspectionDescriptions/ComparisonToNaN.html

2025.3-rc-2325 B
Original Source

Reports any comparisons to Double.NaN or Float.NaN. Such comparisons are never meaningful, as NaN is not equal to anything, including itself. Use the Double.isNaN() or Float.isNaN() methods instead.

Example:

if (x == Double.NaN) {...}

After the quick-fix is applied:

if (Double.isNaN(x)) {...}