whatstheoutput_

#27: Infinity - Infinity

Topic: numbers · Difficulty: ★

console.log(Infinity - Infinity);

Output

NaN

Why

Infinity represents an unbounded numeric overflow, not a real quantity, so arithmetic on it follows the IEEE-754 rules for indeterminate forms rather than intuitive math. Subtracting one infinite value from another has no well-defined result — it isn't 0, and it isn't Infinity — so the spec defines it as NaN, the standard 'this operation makes no numeric sense' sentinel. The same indeterminate-form rule applies to Infinity / Infinity and Infinity * 0, both of which also produce NaN.

More numbers puzzles

Play today's puzzle →