Number.EPSILON
Try it
Właściwość Number.EPSILON
reprezentuje różnicę pomiędzy 1 a najmniejszą liczbą zmiennoprzecinkową większą niż 1.
Jest to właściwość statyczna. Nie musisz tworzyć obiektu Number
, żeby mieć do niej dostęp (użyj Number.EPSILON
).
Property attributes of Number.EPSILON |
|
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
Opis
Wartość właściwości EPSILON
to w przybliżeniu 2.2204460492503130808472633361816E-16
lub 2-52
.
Przykłady
Testowanie równości
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);
}
Specyfikacja
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Number.EPSILON' in that specification. |
Standard | Initial definition. |
ECMAScript (ECMA-262) The definition of 'Number.EPSILON' in that specification. |
Living Standard |
Kompatybilność
BCD tables only load in the browser
Zobacz również
Number
obiekt, do którego należy ta właściwość.