Die Eigenschaft Number.EPSILON
beschreibt den Unterschied zwischen 1 und der kleinsten Gleitpunktzahl größer als 1.
Man muss kein Objekt von Typ Number
erzeugen, um auf diese statische Eigenschaft zuzugreifen. Man muss nur Number.EPSILON
aufrufen.
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.
Eigenschaftsattribute von Number.EPSILON |
|
---|---|
Schreibbar | nein |
Aufzählbar | nein |
Konfigurierbar | nein |
Beschreibung
Die EPSILON
Eigenschaft hat einen ungefähren Wert von 2.2204460492503130808472633361816E-16
order 2-52
.
Beispiele
Testgleichung
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);
}
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Number.EPSILON' in dieser Spezifikation. |
Standard | Initiale Definition. |
ECMAScript (ECMA-262) Die Definition von 'Number.EPSILON' in dieser Spezifikation. |
Lebender Standard |
Browserkompatibilität
BCD tables only load in the browser
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.
Siehe auch
- Das
Number
Objekt.