14 ms·
In JavaScript we're spoiled by having both. There's Number.NEGATIVE_INFINITY and Number.POSITIVE_INFINITY.
by have_faith 3y ago
In JavaScript we're spoiled by having both. There's Number.NEGATIVE_INFINITY and Number.POSITIVE_INFINITY.
- warent 3y agoDon't forget -0 (negative zero)!
- otabdeveloper4 3y agoFloats are approximations of the reals and -0 is just the limit towards zero from the left.
- remram 3y agoWhy, is it odd?
- remram 3y agoBoth what? The question is about even or odd.
- myhf 3y agoNegative Infinity is even, and Positive Infinity is odd.
- Sharlin 3y agoThose are simply the bog-standard IEEE/IEC.754 floating point infinities, so they're the same thing in essentially every mainstream language.
- pelagicAustral 3y agoIn js you could just: npm install is-odd const isOdd = require('is-odd'); console.log(isOdd(∞));