什么是JS Number.MAX_SAFE_INTEGER和MAX_VALUE之间的区别? [英] Whats the difference between JS Number.MAX_SAFE_INTEGER and MAX_VALUE?

查看:2145
本文介绍了什么是JS Number.MAX_SAFE_INTEGER和MAX_VALUE之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Number.MAX_SAFE_INTEGER
9007199254740991

Number.MAX_SAFE_INTEGER 9007199254740991

Number.MAX_VALUE
1.7976931348623157e + 308

Number.MAX_VALUE 1.7976931348623157e+308

我理解 MAX_SAFE_INTEGER 是如何根据JavaScript的双精度浮点算法计算出来的,但这个巨大的地方在哪里最大值来自?如果您使用全部63位作为指数而不是安全的11位,那么它是否会出现?

I understand how MAX_SAFE_INTEGER is computed based on JavaScript's double precision floating point arithmetic, but where does this huge max value come from? Is it the number that comes about if you're using all 63 bits for the exponent instead of the safe 11 bits?

推荐答案

Number.MAX_SAFE_INTEGER 是可以在计算中安全使用的最大整数。

Number.MAX_SAFE_INTEGER is the largest integer which can be used safely in calculations.

例如, Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2 为true - 任何大于MAX_SAFE_INTEGER的整数都不能始终准确地在内存中表示。所有位用于表示数字的数字。

For example, Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2 is true — any integer larger than MAX_SAFE_INTEGER cannot always be represented in memory accurately. All bits are used to represent the digits of the number.

另一方面,Number.MAX_VALUE 是使用双精度浮点表示表示的最大数字。一般来说,数字越大,准确度越低。

Number.MAX_VALUE on the other hand is the largest number possible to represent using a double precision floating point representation. Generally speaking, the larger the number the less accurate it will be.

更多信息双精度浮动维基百科上的点数

这篇关于什么是JS Number.MAX_SAFE_INTEGER和MAX_VALUE之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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