tags:

views:

74

answers:

3

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 ?

+1  A: 

All numbers in Javascript are 64bit (8 bytes) floating point numbers which yields an effective range of 5e-324 (negative) to 1.7976931348623157e+308 (positive)

http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference

Tim Schmelter
+1  A: 

All numbers in JavaScript are 64-bit (double-precision) floating point numbers.

Here's a description of the format and what values can and can't be represented with it.

Syntactic
+2  A: 

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.

LukeH