archives

« Bugzilla Issues Index

#305 — 15.7.4.6: Bugs in Number.prototype.toExponential algorithm


+++ This bug was initially created as a clone of Bug #301 +++

When this Number value is 0 and fractionDigits > 0, according to the algorithm in 15.7.4.6, result is wrong. For example, here are the steps taken for (0).toExponential(1):

1. x = 0
2. f = 1
3. skip
4. s = ""
5. skip
6. skip
7. skip
8. then
a. f = 0
b. m = "0"
c. e = 0
9. skip
10. skip
11. then
a. c = "+"
b. d = "0"
12. skip
13. m = "0e+0"
14. return "0e+0"


The step 8.a "a. Let f = 0." should be "a. if fractionDigits is undefined, then let f = 0.".


This is an ES5 bug that also needs to be repaired in ES6


fixed in May 4 2012 draft