Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
have_faith
on May 2, 2023
|
parent
|
context
|
favorite
| on:
Is infinity an odd or even number? (2011)
In JavaScript we're spoiled by having both. There's Number.NEGATIVE_INFINITY and Number.POSITIVE_INFINITY.
Sharlin
on May 2, 2023
|
next
[–]
Those are simply the bog-standard IEEE/IEC.754 floating point infinities, so they're the same thing in essentially every mainstream language.
remram
on May 2, 2023
|
prev
|
next
[–]
Both what? The question is about even or odd.
myhf
on May 2, 2023
|
parent
|
next
[–]
Negative Infinity is even, and Positive Infinity is odd.
pelagicAustral
on May 2, 2023
|
prev
|
next
[–]
In js you could just:
npm install is-odd const isOdd = require('is-odd'); console.log(isOdd(∞));
warent
on May 2, 2023
|
prev
[–]
Don't forget -0 (negative zero)!
otabdeveloper4
on May 2, 2023
|
parent
|
next
[–]
Floats are approximations of the reals and -0 is just the limit towards zero from the left.
remram
on May 2, 2023
|
parent
|
prev
[–]
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: