Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
73
rated 0 times [  78] [ 5]  / answers: 1 / hits: 26087  / 14 Years ago, mon, may 10, 2010, 12:00:00

I work in Javascript with integer numbers only (mainly adding numbers and shifting them). I wonder how big they can be without loosing any bits.



For example, how big X can be such that 1 << X will represent 2^X ?


More From » javascript

 Answers
60

All numbers in JavaScript are actually IEEE-754 compliant floating-point doubles. These have a 53-bit mantissa which should mean that any integer value with a magnitude of approximately 9 quadrillion or less -- more specifically, 9,007,199,254,740,991 -- will be represented accurately.






NOTICE: in 2018 main browsers and NodeJS are working also with the new Javascript's primitive-type, BigInt, solving the problems with integer value magnitude.


[#96826] Friday, May 7, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cruzs

Total Points: 710
Total Questions: 113
Total Answers: 100

Location: Nepal
Member since Sat, Jul 18, 2020
4 Years ago
cruzs questions
Thu, Nov 26, 20, 00:00, 4 Years ago
Wed, Oct 28, 20, 00:00, 4 Years ago
Wed, Aug 19, 20, 00:00, 4 Years ago
Sun, Aug 2, 20, 00:00, 4 Years ago
;