Closed
Bug 217268
Opened 21 years ago
Closed 21 years ago
Number.toFixed() gives wrong result in 1.5R4.1
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
1.5R5
People
(Reporter: lmb, Assigned: norrisboyd)
References
Details
Attachments
(1 file)
1.45 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312
For certain values, Number.toFixed() gives a wrong result.
Reproducible: Always
Steps to Reproduce:
1. java Shell
2. js> Number(123.223456789).toFixed(12);
Actual Results:
123.223456788900
Expected Results:
123.223456789000
Comment 1•21 years ago
|
||
cc'ing Igor -
Reporter | ||
Comment 2•21 years ago
|
||
I've tracked it down to org.mozilla.javascript.DToA.JS_dtoa(), possibly the most
arcane and unfathomable code I've ever seen. Good luck to whoever tries to fix
this...
Comment 3•21 years ago
|
||
For convenience, here is the corresponding code from SpiderMonkey:
http://lxr.mozilla.org/mozilla/source/js/src/jsdtoa.c
Comment 4•21 years ago
|
||
The reason for the bug is that after cutting all trailing '9' DToA.roundOff
appended to the buffer last digit plus one instead of setting the last
character to that value.
Comment 5•21 years ago
|
||
I committed the fix
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Comment 6•21 years ago
|
||
*** Bug 217965 has been marked as a duplicate of this bug. ***
You need to log in
before you can comment on or make changes to this bug.
Description
•