blob: bbfca4b94fb5125ab2a0e1cc15362c7232809321 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
---
title: Number.EPSILON
slug: Web/JavaScript/Reference/Global_Objects/Number/EPSILON
tags:
- ECMAScript 2015
- JavaScript
- Number
- Property
translation_of: Web/JavaScript/Reference/Global_Objects/Number/EPSILON
---
<div>{{JSRef}}</div>
<p>Die Eigenschaft <strong><code>Number.EPSILON</code></strong> beschreibt den Unterschied zwischen 1 und der kleinsten Gleitpunktzahl größer als 1.</p>
<p>Man muss kein Objekt von Typ {{jsxref("Number")}} erzeugen, um auf diese statische Eigenschaft zuzugreifen. Man muss nur <code>Number.EPSILON</code> aufrufen.</p>
<div>{{EmbedInteractiveExample("pages/js/number-epsilon.html")}}</div>
<div>{{js_property_attributes(0,0,0)}}</div>
<h2 id="Description" name="Description">Beschreibung</h2>
<p>Die <code>EPSILON</code> Eigenschaft hat einen ungefähren Wert von <code>2.2204460492503130808472633361816E-16</code> order <code>2<sup>-52</sup></code>.</p>
<h2 id="Examples" name="Examples">Beispiele</h2>
<h3 id="Testgleichung">Testgleichung</h3>
<pre class="brush: js">x = 0.2;
y = 0.3;
z = 0.1;
equal = (Math.abs(x - y + z) < Number.EPSILON);</pre>
<h2 id="Polyfill">Polyfill</h2>
<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">if</span> <span class="punctuation token">(</span>Number<span class="punctuation token">.</span>EPSILON <span class="operator token">===</span> undefined<span class="punctuation token">) </span><span class="punctuation token">{</span>
Number<span class="punctuation token">.</span>EPSILON <span class="operator token">=</span> Math<span class="punctuation token">.</span><span class="function token">pow</span><span class="punctuation token">(</span><span class="number token">2</span><span class="punctuation token">,</span> <span class="operator token">-</span><span class="number token">52</span><span class="punctuation token">)</span><span class="punctuation token">;
}</span></code>
</pre>
<h2 id="Spezifikationen">Spezifikationen</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Spezifikation</th>
<th scope="col">Status</th>
<th scope="col">Kommentar</th>
</tr>
<tr>
<td>{{SpecName('ES2015', '#sec-number.epsilon', 'Number.EPSILON')}}</td>
<td>{{Spec2('ES2015')}}</td>
<td>Initiale Definition.</td>
</tr>
<tr>
<td>{{SpecName('ESDraft', '#sec-number.epsilon', 'Number.EPSILON')}}</td>
<td>{{Spec2('ESDraft')}}</td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="Browserkompatibilität">Browserkompatibilität</h2>
<p>{{Compat("javascript.builtins.Number.EPSILON")}}</p>
<h2 id="See_also" name="See_also">Siehe auch</h2>
<ul>
<li>Das {{jsxref("Number")}} Objekt.</li>
</ul>
|