4 ms·
yea 1/x is not strictly defined for x=0, but you can extend it in ℜ ∪ {+∞,-∞}, I don't know your math background, but 1/-0 could make you think of limits: 1/0
by caub 10y ago
yea 1/x is not strictly defined for x=0, but you can extend it in ℜ ∪ {+∞,-∞}, I don't know your math background, but 1/-0 could make you think of limits:
1/0 is like 1/0⁺ (limit of 1/x in ]0,+∞[ when x->0) == Infinity.
1/-0 is like 1/0⁻ (limit of 1/x in ]-∞,0[ when x->0) == -Infinity.
1/Infinity is 0 ....
0/0 is however an indefinite form, so it's NaN
so the behavior of JS makes sense
And even if 1/0 and 1/-0 returned NaN, they wouldn't be equal to each other too