I'm currently working on an algorithmic task with (relatively) big arrays and values in them. To be more specific, arrays have 100000 elements where all elements are integers and each element can be as high as 1000000000. So, the question is can JavaScript return wrong element on a given index or vice versa? I suppose so because as it revealed, it looses precision with integers multiplication and other operations after they grow higher than 10 to the power 18.
Asked
Active
Viewed 53 times
-1
-
2Your stated highest value is far from 10^18. – DarthJDG Sep 28 '17 at 10:57
-
4Check `Number.MAX_SAFE_INTEGER` constant in javascript. It's 9007199254740991 (~9 quadrillion) so I don't think that will be an issue – Nico Van Belle Sep 28 '17 at 10:57
-
Have you even tried it yourself ? – Weedoze Sep 28 '17 at 10:59
1 Answers
1
What is JavaScript's highest integer value that a Number can go to without losing precision?
No it won't return the wrong element. Indexes are irrelevant to the Math class

AthMav
- 196
- 1
- 8
-
-
1Duplicates should be commented and (when you can) close-voted, not *answered*. – T.J. Crowder Sep 28 '17 at 11:04