Bug 104145
| Summary: | Number.prototype.{toPrecision,toExponential} should accept out-of-range input for NaN/Infinity | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | André Bargull <andre.bargull> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | Normal | CC: | barraclough, fpizlo, oliver |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
André Bargull
Steps to reproduce:
Test case:
---
js> Number.prototype.toExponential.call(NaN, 555)
typein:63: RangeError: precision 555 out of range
js> Number.prototype.toPrecision.call(NaN, 555)
typein:64: RangeError: precision 555 out of range
---
Expected results:
According to [15.7.4.6 Number.prototype.toExponential (fractionDigits)] step 4 resp. step 6 and according to [15.7.4.7 Number.prototype.toPrecision (precision)] step 4 resp. step 7, toExponential()/toPrecision() return "NaN" (or "Infinity") if the this-argument is `NaN` (or `Infinity`). The actual range check on the input argument happens after (!) handling `NaN`/`Infinity`.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
André Bargull
Does no longer reproduce at r215724.