Closed
Bug 1068612
Opened 10 years ago
Closed 9 years ago
toPrecision accepts arguments that are larger than 21
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: bzbarsky, Unassigned)
References
Details
Per spec, this should throw RangeError: (123.445).toPrecision(55) though it _is_ kinda useful that it works... ;)
Comment 1•10 years ago
|
||
This is allowed per ES5.1, ch. 16 and ES6-draft, ch. 16 [1]: > An implementation may define behaviour other than throwing RangeError for > toFixed, toExponential, and toPrecision when the fractionDigits or > precision argument is outside the specified range. [1] https://people.mozilla.org/~jorendorff/es6-draft.html#sec-error-handling-and-language-extensions
Reporter | ||
Comment 2•10 years ago
|
||
Gah. Then why is that not specified in the toPrecision algorithm itself? This sort of spec monkeypatching is ridiculous. :(
Comment 3•10 years ago
|
||
The allowed extensions are also mentioned after the algorithms for toPrecision() and friends [1]. Maybe an additional in-line note in the actual algorithm should be added? [1] https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.prototype.toprecision
Reporter | ||
Comment 4•10 years ago
|
||
Yeah. That would be a lot better than this COMEFROM style of specification.
Comment 5•10 years ago
|
||
Filed https://bugs.ecmascript.org/show_bug.cgi?id=3230
Comment 6•9 years ago
|
||
Resolving as Won't Fix - Higher precision is allowed per spec.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
Comment 7•7 years ago
|
||
I think it could still make sense to revisit this; posted a little more at https://bugzilla.mozilla.org/show_bug.cgi?id=90551#c8 (sorry, not sure how to mark it as a duplicate here). Does anyone have an idea what the motivation for the larger range beyond integer precision is? If the larger range is useful, it could be implemented in other engines and standardized that way.
You need to log in
before you can comment on or make changes to this bug.
Description
•