From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/number/epsilon/index.html | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/number/epsilon/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/number/epsilon') diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/epsilon/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/epsilon/index.html new file mode 100644 index 0000000000..fea6ee1bb8 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/number/epsilon/index.html @@ -0,0 +1,114 @@ +--- +title: Number.EPSILON +slug: Web/JavaScript/Reference/Global_Objects/Number/EPSILON +translation_of: Web/JavaScript/Reference/Global_Objects/Number/EPSILON +--- +
{{JSRef}}
+ +

Number.EPSILON 属性表示 1 与{{jsxref("Number")}}可表示的大于 1 的最小的浮点数之间的差值。

+ +

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

+ +
{{js_property_attributes(0, 0, 0)}}
+ +

描述

+ +

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

+ +

示例

+ +

测试是否相等

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

Polyfill

+ +
if (Number.EPSILON === undefined) {
+    Number.EPSILON = Math.pow(2, -52);
+}
+ + + +

规范

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES6', '#sec-number.epsilon', 'Number.EPSILON')}}{{Spec2('ES6')}}最初定义
{{SpecName('ESDraft', '#sec-number.epsilon', 'Number.EPSILON')}}{{Spec2('ESDraft')}}
+ +

浏览器兼容性

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("25.0")}}{{CompatNo}}{{CompatVersionUnknown}}9
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25.0")}}{{CompatNo}}{{CompatNo}}9
+
+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf