What is the result of the following operation defined by IEEE754. (NaN == NaN)
What is the result of the IEEE-754 comparison:
(NaN == NaN) ?
0/0 or sqrt(-1)).
false. So NaN == NaN is false.
isnan() (C/C++),
Number.isNaN() (JavaScript), or platform-specific functions — not equality.
(NaN == NaN) → false
// C (IEEE-754 floating point)
double x = 0.0/0.0; // NaN
printf("%d\n", x == x); // prints 0 (false)
printf("%d\n", isnan(x)); // prints 1 (true)
// JavaScript
let x = NaN;
console.log(x == x); // false
console.log(Number.isNaN(x));// true
// Python
import math
x = float('nan')
print(x == x) # False
print(math.isnan(x)) # True
Extra note: IEEE-754 also provides signaling and quiet NaNs and treats all NaNs as unordered for comparisons. Many numeric libraries provide utilities to handle NaNs explicitly (propagation, tests, or replacement).
Reinforce your conceptual grasp with related questions from CUET-MCA 2025:
Take timed full-length mock tests with authentic question distributions, negative marking (+12/-3 in Math), and instant All India Rank calculation.
Start Free Mock Test Series →