Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: