Number.MIN_VALUE
Number.MIN_VALUE
静态数据属性表示 JavaScript 中可表示的最小正数值。
¥The Number.MIN_VALUE
static data property represents the smallest positive numeric value representable in JavaScript.
Try it
值
描述
¥Description
Number.MIN_VALUE
是可以在浮点精度内表示的最小正数(不是最大负数),换句话说,是最接近 0 的数字。ECMAScript 规范没有定义实现需要支持的精确值 - 相反,规范说,"必须是实现实际可以表示的最小非零正值"。这是因为小的 IEEE-754 浮点数是 denormalized,但实现不需要支持这种表示,在这种情况下 Number.MIN_VALUE
可能会更大。
¥Number.MIN_VALUE
is the smallest positive number (not the most negative number) that can be represented within float precision — in other words, the number closest to 0. The ECMAScript spec doesn't define a precise value that implementations are required to support — instead the spec says, "must be the smallest non-zero positive value that can actually be represented by the implementation". This is because small IEEE-754 floating point numbers are denormalized, but implementations are not required to support this representation, in which case Number.MIN_VALUE
may be larger.
实际上,它在 V8(Chrome、Edge、Node.js 使用)、SpiderMonkey(Firefox 使用)和 JavaScriptCore(Safari 使用)等主流引擎中的精确值为 2-1074,或者 5E-324
。
¥In practice, its precise value in mainstream engines like V8 (used by Chrome, Edge, Node.js), SpiderMonkey (used by Firefox), and JavaScriptCore (used by Safari) is 2-1074, or 5E-324
.
由于 MIN_VALUE
是 Number
的静态属性,因此你始终将其用作 Number.MIN_VALUE
,而不是作为数字值的属性。
¥Because MIN_VALUE
is a static property of Number
, you always use it as Number.MIN_VALUE
, rather than as a property of a number value.
示例
使用 MIN_VALUE
¥Using MIN_VALUE
以下代码将两个数值相除。如果结果大于或等于 MIN_VALUE
,则调用 func1
函数;否则,调用 func2
函数。
¥The following code divides two numeric values. If the result is greater than or equal to MIN_VALUE
, the func1
function is called; otherwise, the func2
function is called.
if (num1 / num2 >= Number.MIN_VALUE) {
func1();
} else {
func2();
}
规范
Specification |
---|
ECMAScript Language Specification # sec-number.min_value |
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also