2.1.96 [ECMA-262-1999] Section 15.7.4.6, Number.prototype.toExponential (fractionDigits)

V0145:

1. Let x be the this number value.

2. Let f be ToInteger(fractionDigits).

  1. __If browser is Internet Explorer 7 or 8 and f is +∞ or -∞, then let f be 0.__

3. If x is NaN, return the string "NaN".

4. Let s be the empty string.

5. If x ≥ 0, go to step 8.

6. Let s be "-".

7. Let x = -x.

8. If x = +∞, let m = "Infinity" and go to step 30.

9. If fractionDigits __was not passed as an argument __#is undefined#, go to step 14.

10. If f < 0 or f > 20, throw a RangeError exception.

11. If x = 0, go to step 16.

12. Let e and n be integers such that 10fn < 10f+1 and for which the exact mathematical value of n×10e-f-x is as close to zero as possible. If there are two such sets of e and n, pick the e and n for which n×10e-f is larger.

13. Go to step 20.

14. If x ≠ 0, go to step 19.

15. Let f = 0.

16. Let m be the string consisting of f+1 occurrences of the character '0'.

17. Let e = 0.

18. Go to step 21.

19. Let e, n, and f be integers such that f ≥ 0, 10fn < 10f+1, the number value for n×10e-f is x, and f is as small as possible. Note that the decimal representation of n has f+1 digits, n is not divisible by 10, and the least significant digit of n is not necessarily uniquely determined by these criteria.

20. Let m be the string consisting of the digits of the decimal representation of n (in order, with no leading zeroes).

21. If f = 0, go to step 24.

22. Let a be the first character of m, and let b be the remaining f characters of m.

23. Let m be the concatenation of the three strings a, ".", and b.

24. If e = 0, let c = "+" and d = "0" and go to step 29.

25. If e > 0, let c = "+" and go to step 28.

26. Let c = "-".

27. Let e = -e.

28. Let d be the string consisting of the digits of the decimal representation of e (in order, with no leading zeroes).

29. Let m be the concatenation of the four strings m, "e", c, and d.

30. Return the concatenation of the strings s and m.

The length property of the toExponential method is 1.

V0146:

An implementation is permitted to extend the behaviour of toExponential for values of fractionDigits less than 0 or greater than 20. In this case toExponential would not necessarily throw RangeError for such values. __JScript 5.x under Internet Explorer 7 or 8 treats as if it were the value 0 any value of fractionDigits that when converted to an integer is equal to either +∞ or -∞.__