Number.EPSILON
property represents the difference between 1 and the smallest floating point number greater than 1.
You do not have to create a
Number
object to access this static property (use
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
|
|
|---|---|
| 可写 | no |
| 可枚举 | no |
| 可配置 | no |
EPSILON
property has a value of approximately
2.2204460492503130808472633361816E-16
,或
2
-52
.
if (Number.EPSILON === undefined) {
Number.EPSILON = Math.pow(2, -52);
}
x = 0.2; y = 0.3; z = 0.1; equal = (Math.abs(x - y + z) < Number.EPSILON);
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'Number.EPSILON' in that specification. |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
更新 GitHub 上的兼容性数据| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
EPSILON
|
Chrome 34 | Edge 12 | Firefox 25 | IE No | Opera 21 | Safari 9 | WebView Android ≤37 | Chrome Android 34 | Firefox Android 25 | Opera Android 21 | Safari iOS 9 | Samsung Internet Android 2.0 | nodejs 0.12 |
完整支持
不支持
Number
object it belongs to.
Number
Number.isFinite()
Number.isInteger()
Number.isNaN()
Number.isSafeInteger()
Number.parseFloat()
Number.parseInt()
Number.prototype.toExponential()
Number.prototype.toFixed()
Number.prototype.toLocaleString()
Number.prototype.toPrecision()
Number.prototype.toSource()
Number.prototype.toString()
Number.prototype.valueOf()
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()