Closed
Bug 11178
Opened 25 years ago
Closed 25 years ago
Incorrect number-to-string conversion
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
RESOLVED
FIXED
People
(Reporter: waldemar, Assigned: waldemar)
Details
The number 1e23 displays as 9.999999999999999e+22. According to ECMA, it must display as 1e23. More detail: Converting "1e23" to an IEEE double using IEEE's standard round-to- nearest mode yields the IEEE double value 1.0101001011010000001011000111111000010100101011110110e76 (0x44B52D02C7E14AF6 encoded as a double). This is exactly equal to 99999999999999991611392. On output, ECMA 9.8 step 5 specifies that the significand must be as small as possible while still having the printed number turn into the same double value if converted back. If we choose the significand to be 1 and the exponent to be 23, then the resulting number is "1e+23" and it does convert back to 99999999999999991611392, as required. Hence "1e+23" is the correct answer. [As a general rule, *every* conversion of string->double->string where the initial string has both: fewer than about 15 significant digits; an exponent within the double non-denormalized range must return a number that looks like the original string (possibly sans leading and trailing zeros and in fixed instead of exponential or exponential instead of fixed notation. This rule can be mathematically inferred from the properties specified in the ECMA spec.] Other test cases that currently fail are 5e22, 1.6e24, etc. Waldemar
Updated•25 years ago
|
Assignee: mccabe → rogerl
Comment 1•25 years ago
|
||
Roger, can you take a look at this? CC'ing Clayton.
Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Updated•25 years ago
|
Assignee: rogerl → waldemar
Status: ASSIGNED → NEW
Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Updated•25 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•