Javascript中的数字和有效范围

edw*_*pku 5 javascript

Javascript中的所有数字都是64位(8字节)浮点数,但为什么JavaScript的有效范围是5e-324(负数)到1.7976931348623157e + 308(正数)?

Mat*_*all 8

因为这是IEEE 754规范定义的内容.

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)
Run Code Online (Sandbox Code Playgroud)