Question 72

Computer Awareness Number representations Easy

What is the result of the following operation defined by IEEE754. (NaN == NaN)

(A) false
(B) true
(C) error
(D) 1
✓ Correct Answer: Option A Verified Solution

📘 Step-by-Step Solution & Detailed Explanation:

IEEE-754: Is (NaN == NaN) true?

Question

What is the result of the IEEE-754 comparison: (NaN == NaN) ?

Answer: false

Why?

  1. By the IEEE-754 standard, NaN (Not-a-Number) represents an undefined or unrepresentable value (for example, the result of 0/0 or sqrt(-1)).
  2. The standard defines all comparisons with NaN as unordered. In particular, equality comparisons involving NaN always evaluate to false. So NaN == NaN is false.
  3. To test whether a value is NaN you must use a dedicated predicate such as isnan() (C/C++), Number.isNaN() (JavaScript), or platform-specific functions — not equality.
Final result: (NaN == NaN) → false

Examples (behavior in common languages)

// 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).

Practice Similar Number representations Questions

Reinforce your conceptual grasp with related questions from CUET-MCA 2025:

Q56 Perform the arithmetic addition of the two decimal numbers given in List-I...
Solve →
Q65 Which of the following statement is true about IEEE754 representation of...
Solve →
Q1 Match List-I with List-II |c|l| List-I & List-II \\ (A)\ Seek Time & (I)\...
Solve →
Q4 In case of Binary search tree which of the following procedure's running...
Solve →
Q7 External fragmentation occurs
Solve →
Full-Length Test Series

Prepare for CUET-MCA Under Real Exam Conditions

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 →