blob: 19e6c4e2efb9900137d003c131cabb9e4f07817d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
---
title: Number.EPSILON
slug: Web/JavaScript/Reference/Global_Objects/Number/EPSILON
tags:
- ECMAScript 2015
- JavaScript
- Number
- プロパティ
- ポリフィル
browser-compat: javascript.builtins.Number.EPSILON
translation_of: Web/JavaScript/Reference/Global_Objects/Number/EPSILON
---
{{JSRef}}
**`Number.EPSILON`** プロパティは、1 から 1 より大きな浮動小数点の最小値の差を表します。
この静的なプロパティにアクセスするために {{jsxref("Number")}} オブジェクトを生成する必要はありません (`Number.EPSILON` を使用してください)。
{{EmbedInteractiveExample("pages/js/number-epsilon.html")}}{{js_property_attributes(0, 0, 0)}}
## 解説
`EPSILON` プロパティは およそ `2.2204460492503130808472633361816E-16`、または `2^-52` の値を持っています。
## 例
### 同等性のテスト
```js
x = 0.2;
y = 0.3;
z = 0.1;
equal = (Math.abs(x - y + z) < Number.EPSILON);
```
## ポリフィル
```js
if (Number.EPSILON === undefined) {
Number.EPSILON = Math.pow(2, -52);
}
```
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}
## 関連情報
- `Number.EPSILON` のポリフィルは [`core-js`](https://github.com/zloirock/core-js#ecmascript-number) で利用できます
- 所属先の {{jsxref("Number")}} オブジェクト
|