| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Precision_range | [Back] [Original] |
Get to know MDN better
The JavaScript exception "precision is out of range" occurs when a number that's
outside of the allowed range was passed into toExponential, toFixed, or toPrecision.
RangeError: toExponential() argument must be between 0 and 100 (V8-based & Safari) RangeError: toFixed() digits argument must be between 0 and 100 (V8-based & Safari) RangeError: toPrecision() argument must be between 1 and 100 (V8-based & Safari) RangeError: precision -1 out of range (Firefox)
RangeError
There was an out of range precision argument in one of these methods:
Number.prototype.toExponential(), which requires the arguments to be between 0 and 100, inclusive.Number.prototype.toFixed(), which requires the arguments to be between 0 and 100, inclusive.Number.prototype.toPrecision(), which requires the arguments to be between 1 and 100, inclusive.(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
(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
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |