aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/errors/precision_range/index.md
diff options
context:
space:
mode:
authorjulieng <julien.gattelier@gmail.com>2021-08-03 08:03:09 +0200
committerSphinxKnight <SphinxKnight@users.noreply.github.com>2021-09-03 08:08:25 +0200
commit844f5103992238c0c23203286dad16a466e89c97 (patch)
treed537708951bb2b61be8192ffacc05a0ce6804f89 /files/fr/web/javascript/reference/errors/precision_range/index.md
parenta70fd5b73ecb10bec3906640023e2a1a46e118a2 (diff)
downloadtranslated-content-844f5103992238c0c23203286dad16a466e89c97.tar.gz
translated-content-844f5103992238c0c23203286dad16a466e89c97.tar.bz2
translated-content-844f5103992238c0c23203286dad16a466e89c97.zip
move *.html to *.md
Diffstat (limited to 'files/fr/web/javascript/reference/errors/precision_range/index.md')
-rw-r--r--files/fr/web/javascript/reference/errors/precision_range/index.md99
1 files changed, 99 insertions, 0 deletions
diff --git a/files/fr/web/javascript/reference/errors/precision_range/index.md b/files/fr/web/javascript/reference/errors/precision_range/index.md
new file mode 100644
index 0000000000..52adf5bcd1
--- /dev/null
+++ b/files/fr/web/javascript/reference/errors/precision_range/index.md
@@ -0,0 +1,99 @@
+---
+title: 'RangeError: precision is out of range'
+slug: Web/JavaScript/Reference/Errors/Precision_range
+tags:
+ - Erreurs
+ - JavaScript
+ - RangeError
+translation_of: Web/JavaScript/Reference/Errors/Precision_range
+original_slug: Web/JavaScript/Reference/Erreurs/Precision_range
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="Message">Message</h2>
+
+<pre class="syntaxbox">RangeError: The number of fractional digits is out of range (Edge)
+RangeError: The precision is out of range (Edge)
+RangeError: precision {0} out of range (Firefox)
+RangeError: toExponential() argument must be between 0 and 20 (Chrome)
+RangeError: toFixed() digits argument must be between 0 and 20 (Chrome)
+RangeError: toPrecision() argument must be between 1 and 21 (Chrome)
+</pre>
+
+<h2 id="Type_d'erreur">Type d'erreur</h2>
+
+<p>{{jsxref("RangeError")}}</p>
+
+<h2 id="Quel_est_le_problème">Quel est le problème ?</h2>
+
+<p>Un argument dont la précision est en dehors de l'intervalle valide, prévu par le moteur JavaScript, a été utilisé pour une de ces méthodes :</p>
+
+<ul>
+ <li>{{jsxref("Number.prototype.toExponential()")}}</li>
+ <li>{{jsxref("Number.prototype.toFixed()")}}</li>
+ <li>{{jsxref("Number.prototype.toPrecision()")}}</li>
+</ul>
+
+<p>Généralement, ces méthodes acceptent des arguments de précision compris entre 0 et 20 (voire 21). Cependant, la spécification ECMAScript permet de gérer des valeurs en dehors de cet intervalle.</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Méthode</th>
+ <th scope="col">Firefox (SpiderMonkey)</th>
+ <th scope="col">Chrome, Opera (V8)</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{jsxref("Number.prototype.toExponential()")}}</td>
+ <td>0 to 100</td>
+ <td>0 to 20</td>
+ </tr>
+ <tr>
+ <td>{{jsxref("Number.prototype.toFixed()")}}</td>
+ <td>-20 to 100</td>
+ <td>0 to 20</td>
+ </tr>
+ <tr>
+ <td>{{jsxref("Number.prototype.toPrecision()")}}</td>
+ <td>1 to 100</td>
+ <td>1 to 21</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Exemples">Exemples</h2>
+
+<h3 id="Exemples_invalides">Exemples invalides</h3>
+
+<pre class="brush: js example-bad">77.1234.toExponential(-1); // RangeError
+77.1234.toExponential(101); // RangeError
+
+2.34.toFixed(-100); // RangeError
+2.34.toFixed(1001); // RangeError
+
+1234.5.toPrecision(-1); // RangeError
+1234.5.toPrecision(101); // RangeError
+</pre>
+
+<h3 id="Exemples_valides">Exemples valides</h3>
+
+<pre class="brush: js example-good">77.1234.toExponential(4); // 7.7123e+1
+77.1234.toExponential(2); // 7.71e+1
+
+2.34.toFixed(1); // 2.3
+2.35.toFixed(1); // 2.4 (note that it rounds up in this case)
+
+5.123456.toPrecision(5); // 5.1235
+5.123456.toPrecision(2); // 5.1
+5.123456.toPrecision(1); // 5
+</pre>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li>{{jsxref("Number.prototype.toExponential()")}}</li>
+ <li>{{jsxref("Number.prototype.toFixed()")}}</li>
+ <li>{{jsxref("Number.prototype.toPrecision()")}}</li>
+</ul>