--- title: Number.EPSILON slug: Web/JavaScript/Reference/Global_Objects/Number/EPSILON tags: - ECMAScript 2015 - JavaScript - Number - Właściwość translation_of: Web/JavaScript/Reference/Global_Objects/Number/EPSILON original_slug: Web/JavaScript/Referencje/Obiekty/Number/EPSILON ---
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 {{jsxref("Number")}}, żeby mieć do niej dostęp (użyj Number.EPSILON
).
Wartość właściwości EPSILON
to w przybliżeniu 2.2204460492503130808472633361816E-16
lub 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); }
Specification | Status | Comment |
---|---|---|
{{SpecName('ES2015', '#sec-number.epsilon', 'Number.EPSILON')}} | {{Spec2('ES2015')}} | Initial definition. |
{{SpecName('ESDraft', '#sec-number.epsilon', 'Number.EPSILON')}} | {{Spec2('ESDraft')}} |
{{Compat("javascript.builtins.Number.EPSILON")}}