Search code examples
javascriptcomputer-sciencebit32bit-64bit

Is Number.MAX_SAFE_INTEGER has value of (2^53 - 1) in 32-bit computer


The MDN Web Docs refers that the Number.MAX_SAFE_INTEGER constant represents the maximum safe integer in JavaScript which has value of 2^53 - 1.

my question: is Number.MAX_SAFE_INTEGER has also value of (2^53 - 1) in 32-bit computer?

and if yes it has the same value how can JavaScript store this number (2^53 - 1) in 32 bits?!


Solution

  • Yes. All JavaScript Numbers are represented using IEEE 754 binary64 (A.K.A. double precision floating point). This format takes 64 bits of space, but most modern 32-bit processors support it natively, and even if they didn't, it would be possible to implement floating point operations in software.

    The "32-bit" in 32-bit processor refers to the word size.