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)

x86
Windows 2000
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: lmb, Assigned: norrisboyd)

References

Details

Attachments

(1 file)

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
cc'ing Igor -
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...
For convenience, here is the corresponding code from SpiderMonkey: http://lxr.mozilla.org/mozilla/source/js/src/jsdtoa.c
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.
I committed the fix
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
*** Bug 217965 has been marked as a duplicate of this bug. ***
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: