aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/javascript/reference/errors/precision_range/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:41:45 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:41:45 -0500
commit1109132f09d75da9a28b649c7677bb6ce07c40c0 (patch)
tree0dd8b084480983cf9f9680e8aedb92782a921b13 /files/es/web/javascript/reference/errors/precision_range/index.html
parent4b1a9203c547c019fc5398082ae19a3f3d4c3efe (diff)
downloadtranslated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.gz
translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.bz2
translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.zip
initial commit
Diffstat (limited to 'files/es/web/javascript/reference/errors/precision_range/index.html')
-rw-r--r--files/es/web/javascript/reference/errors/precision_range/index.html96
1 files changed, 96 insertions, 0 deletions
diff --git a/files/es/web/javascript/reference/errors/precision_range/index.html b/files/es/web/javascript/reference/errors/precision_range/index.html
new file mode 100644
index 0000000000..22c37598ff
--- /dev/null
+++ b/files/es/web/javascript/reference/errors/precision_range/index.html
@@ -0,0 +1,96 @@
+---
+title: 'RangeError: precision is out of range'
+slug: Web/JavaScript/Reference/Errors/Precision_range
+translation_of: Web/JavaScript/Reference/Errors/Precision_range
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<p>The JavaScript exception "precision is out of range" occurs when a number that's outside of the range of 0 and 20 (or 21) was passed into <code>toFixed</code> or <code>toPrecision</code>.</p>
+
+<h2 id="Message">Message</h2>
+
+<pre class="syntaxbox notranslate">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="Error_type">Error type</h2>
+
+<p>{{jsxref("RangeError")}}</p>
+
+<h2 id="Que_salió_mal">Que salió mal?</h2>
+
+<p>Fué un argumento preciso fuera de rango en uno de estos metodos:</p>
+
+<ul>
+ <li>{{jsxref("Number.prototype.toExponential()")}}</li>
+ <li>{{jsxref("Number.prototype.toFixed()")}}</li>
+ <li>{{jsxref("Number.prototype.toPrecision()")}}</li>
+</ul>
+
+<p>El rango permitido para estos metodos usualmente esta entre 0 o 20 (o 21). De todas formas la <span><span>especificación</span></span>  ECMAScript permite extender este rango.</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Method</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="Examples">Examples</h2>
+
+<h3 id="Casos_no_validos">Casos no validos</h3>
+
+<pre class="brush: js example-bad notranslate">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="Casos_validos">Casos validos</h3>
+
+<pre class="brush: js example-good notranslate">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="También_te_puede_interesar">También te puede interesar:</h2>
+
+<ul>
+ <li>{{jsxref("Number.prototype.toExponential()")}}</li>
+ <li>{{jsxref("Number.prototype.toFixed()")}}</li>
+ <li>{{jsxref("Number.prototype.toPrecision()")}}</li>
+</ul>