2

JavaScript comes with 64bit float numbers for all numeric literals, and the storage layout and range is regulated under ITEE 754.

On the other hand, I learned that the float has a range of ± ~10^-323.3 to ~10^308.3 and an as-reliable-as-possible precision. Integer has a range of -2^53 - 2^53 and a reliable precision.

ITEE 754 explains the behavior of float numbers but I get confused about the integer in JS. How is the range of precision generated from the 64bit data format?

[Solved] The value is stored in the fraction position. 1 is (1+0)*2^0, 2 is (1 + 0) * 2^1, 3 is (1 + 2^-1)*2^1... Any number between -2^53 and 2^53 could be expressed precisely. As there is a leading 1 for all fraction, the range is -2^53 to 2^53

1
  • Typo: is IEEE instead of ITEE. Commented Jan 10, 2016 at 22:10

3 Answers 3

2

Actually it is -2^52 to 2^52. What happens is that integer is actually stored in floating point format. At yout URL you can see that from 64 bits 52 bits are used for fraction. That is where number is actually stored.

Sign up to request clarification or add additional context in comments.

Comments

0

As reliable as possible means precisely the 2^52 range. While you can represent numbers larger than that you start skiping some integers after this point.

Comments

0

[Solved myself] The value is stored in the fraction position. 1 is (1+0)*2^0, 2 is (1 + 0) * 2^1, 3 is (1 + 2^-1)*2^1... Any number between -2^53 and 2^53 could be expressed precisely. As there is a leading 1 for all fraction, the range is -2^53 to 2^53

1 Comment

actually Andrey gave the solution first

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.