Javascript numbers and effective range

All numbers in Javascript are 64-bit (8 bytes) floating point numbers, but why is the effective JavaScript range of 5e-324 (negative) to 1.7976931348623157e + 308 (positive)?

+5
source share
2 answers

Because it is defined by the IEEE 754 specification .

0x 0000 0000 0000 0001 = 2⁻¹⁰²²⁻⁵² ≈ 4.9406564584124654 x 10⁻³²⁴ (Min subnormal positive double)
0x 000f ffff ffff ffff = 2⁻¹⁰²² - 2⁻¹⁰²²⁻⁵² ≈ 2.2250738585072009 x 10⁻³⁰⁸ (Max subnormal positive double)
0x 0010 0000 0000 0000 = 2⁻¹⁰²² ≈ 2.2250738585072014 x 10⁻³⁰⁸ (Min normal positive double)
0x 7fef ffff ffff ffff = (1 + (1 - 2⁻⁵²)) x 2¹⁰²³ ≈ 1.7976931348623157 x 10³⁰⁸ (Max Double)
+8
source

Due to the abnormal values; see for example http://en.wikipedia.org/wiki/Denormal_number . They expand the range of floating point values ​​so that the values ​​are closer to zero than otherwise would be possible.

, , ; , .

+4

All Articles