Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialshadryck
12,151 PointsparseInt returns Infinity?
I'm curious about why and how this works. Is it related to 32 / 16 bits integers not being able to contain higher numbers or something like that?
parseInt("99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999") // returns 1e+308
parseInt("999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999") // one 9 more returns Infinity
1 Answer
Jonathan Cousins
4,160 PointsThankfully the lovely people over at MDN have the answer.
The Number.MAX_VALUE property represents the maximum numeric value representable in JavaScript.
...
The MAX_VALUE property has a value of approximately 1.79E+308. Values larger than MAX_VALUE are represented as "Infinity".
shadryck
12,151 Pointsshadryck
12,151 PointsAh, I've totally missed that. Thank you for taking the time to link it.
Jonathan Cousins
4,160 PointsJonathan Cousins
4,160 PointsYou're welcome. =)