RESOLVED FIXED 5308
Number.toFixed doesn't include leading zero
https://bugs.webkit.org/show_bug.cgi?id=5308
Summary Number.toFixed doesn't include leading zero
Bob Ippolito
Reported 2005-10-09 11:33:59 PDT
(0.5).toFixed(1) is ".5". (0.5).toString() is "0.5" and other browsers return "0.5" for both.
Attachments
Patch and test case for 5308 (2.26 KB, patch)
2006-01-03 20:59 PST, Ricci Adams
eric: review+
Ricci Adams
Comment 1 2006-01-03 02:43:41 PST
ECMA-262 Section 15.7.4.5 states that: 13. Let k be the number of characters in m. 14. If k > f, go to step 18. We are implementing this by creating an if block containing steps 15-17. Unfortuately, the statement we are using is: if (m.size() < f) { // Execute steps 15-17 } // Step 18... Hence, we are assuming that (k > f) is the same as !(k < f). This is logically not the case. I believe that the correct line is: if (m.size() <= f) { Unfortuately, I'm too tired to create/test a patch now. I will try to attach one later this week.
Ricci Adams
Comment 2 2006-01-03 20:59:26 PST
Created attachment 5468 [details] Patch and test case for 5308 Patch attached. This is basically changing the < to a <=. I also changed m.size() to k in order to make the code read more like the algorithm.
Eric Seidel (no email)
Comment 3 2006-01-03 22:26:20 PST
Comment on attachment 5468 [details] Patch and test case for 5308 Looks fine. An even better test case would print "success" or "failure" to be more clear.
Note You need to log in before you can comment on or make changes to this bug.