Hacker News new | past | comments | ask | show | jobs | submit login

In JavaScript we're spoiled by having both. There's Number.NEGATIVE_INFINITY and Number.POSITIVE_INFINITY.



Those are simply the bog-standard IEEE/IEC.754 floating point infinities, so they're the same thing in essentially every mainstream language.


Both what? The question is about even or odd.


Negative Infinity is even, and Positive Infinity is odd.


In js you could just:

    npm install is-odd

    const isOdd = require('is-odd');
    console.log(isOdd(∞));


Don't forget -0 (negative zero)!


Floats are approximations of the reals and -0 is just the limit towards zero from the left.


Why, is it odd?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: