0 / 0
outputs NaN
while 1 / 0
outputs Infinity
How javascript evaluates the first mathematical operation?
0 / 0
outputs NaN
while 1 / 0
outputs Infinity
How javascript evaluates the first mathematical operation?
As per spec
0 / 0 outputs NaN because
Division of a zero by a zero results in NaN; division of zero by any other finite value results in zero, with the sign determined by the rule already stated above.
and 1 / 0 outputs Infinity because
Division of a nonzero finite value by a zero results in a signed infinity. The sign is determined by the rule already stated above.
Point 7 and 8 in the section 12.6.3.2 Applying the / Operator (unordered list)
In javascript, 0 / 0
and 1 / 0
denote the division of IEEE754 floating point type arguments.
This floating point specification is very specific about what must happen when a division where the denominator is zero is evaluated. It returns
Hence 0 / 0
is NaN, and 1 / 0
is +Infinity.
Note that in other languages (e.g. C, C++, and Java) your division would take place in integer arithmetic, and integer division by zero is not defined.
0/0 is the expression which math can not execute. that is why it is Not_A_Number.