Number.EPSILON
Number.EPSILON
プロパティは、1 から 1 より大きな浮動小数点の最小値の差を表します。
この静的なプロパティにアクセスするために Number
オブジェクトを生成する必要はありません (Number.EPSILON
を使用してください)。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Number.EPSILON のプロパティ属性 |
|
---|---|
書込可能 | 不可 |
列挙可能 | 不可 |
設定可能 | 不可 |
解説
EPSILON
プロパティは およそ 2.2204460492503130808472633361816E-16
、または 2-52
の値を持っています。
例
同等なことをテストする
x = 0.2;
y = 0.3;
z = 0.1;
equal = (Math.abs(x - y + z) < Number.EPSILON);
ポリフィル
if (Number.EPSILON === undefined) {
Number.EPSILON = Math.pow(2, -52);
}
仕様書
ブラウザーの互換性
BCD tables only load in the browser
関連情報
- 所属先の
Number
オブジェクト