We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Number.EPSILON 属性表示 1 和大于 1 的最小值(可表示为 Number)的差值。

你不必创建一个 Number 对象来访问这个静态属性(直接使用 Number.EPSILON)。

Number.EPSILON 属性的属性特性:
writable false
enumerable false
configurable false

描述

EPSILON 属性的值接近于 2.2204460492503130808472633361816E-16,或者 2-52。

示例

测试是否相等

x = 0.2;
y = 0.3;
z = 0.1;
equal = (Math.abs(x - y + z) < Number.EPSILON);

规范

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
Number.EPSILON
Standard 最初定义
ECMAScript Latest Draft (ECMA-262)
Number.EPSILON
Draft  

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 25.0 (25.0) 未实现 (Yes) 9
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 未实现 25.0 (25.0) 未实现 未实现 9

相关链接

文档标签和贡献者

此页面的贡献者: AlexChao, jokeviner
最后编辑者: AlexChao,