在JavaScript中,整数如何在存储布局中表示? [英] In JavaScript, how is integer represented in storage layout?

查看:85
本文介绍了在JavaScript中,整数如何在存储布局中表示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaScript为所有数字文字提供64位浮点数,并且存储布局和范围受

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

另一方面,我了解到浮点数的范围为±〜10 ^ -323.3至〜10 ^ 308.3,并且具有尽可能可靠的精度.整数的范围为-2 ^ 53-2 ^ 53,并且精度可靠.

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解释了浮点数的行为,但是我对JS中的整数感到困惑.如何从64位数据格式生成精度范围?

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?

[已解决] 该值存储在分数位置. 1 is (1+0)*2^02 is (1 + 0) * 2^13 is (1 + 2^-1)*2^1 ... -2 ^ 53和2 ^ 53之间的任何数字都可以精确表示. 由于所有分数都有前导1,因此范围是-2 ^ 53至2 ^ 53

[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是(1 + 0)* 2 ^ 0,2是(1 + 0)* 2 ^ 1,3是(1 + 2 ^ -1)* 2 ^ 1 ... -2 ^ 53和2之间的任何数字^ 53可以精确表达.由于所有分数都有前导1,因此范围是-2 ^ 53至2 ^ 53

[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

这篇关于在JavaScript中,整数如何在存储布局中表示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆