RESOLVED FIXED Bug 5307
Number.toFixed doesn't round 0.5 up
https://bugs.webkit.org/show_bug.cgi?id=5307
Summary Number.toFixed doesn't round 0.5 up
Bob Ippolito
Reported 2005-10-09 11:32:24 PDT
Math.round() rounds 0.5 up, and (0.51).toFixed(0) rounds up, but (0.5).toFixed(0) does not. This is inconsistent with other browsers and itself.
Attachments
Patch for 5307, including test case (2.25 KB, patch)
2006-01-03 01:48 PST, Ricci Adams
ggaren: review+
Ricci Adams
Comment 1 2006-01-03 01:48:43 PST
Created attachment 5444 [details] Patch for 5307, including test case From my interpretation (and Maciej's) of ECMA-262 Section 15.7.4.5, it looks like step 10 means to round the number. Hence, 0.5.toFixed(0) should indeed be 1.
Ricci Adams
Comment 2 2006-01-03 01:57:40 PST
Note: I do not believe that the summary for this bug is correct. (0.51).toFixed() does round up to 1, it is only 0.5 that is (was) not working. Hence, the summary should probably read "Number.toFixed doesn't round up for 0.5"
Geoffrey Garen
Comment 3 2006-01-03 09:25:31 PST
Comment on attachment 5444 [details] Patch for 5307, including test case r=me
Darin Adler
Comment 4 2006-01-06 09:34:22 PST
Should really put in a test for -0.5 too.
Alexey Proskuryakov
Comment 5 2006-06-22 22:01:03 PDT
*** Bug 9550 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.