string Number.prototype.toExponential(fractionDigits:uint|mixed) throws RangeError
Convert the number to a string having one digit left of the decimal point and fractionDigits on the right. Always outputs exponential notation.
If fractionDigits is undefined use as many digits as is needed to represent the number uniquely, just as in ToString, except this always uses the exponential notation.
string Number.prototype.toExponential.length = 1
If toExponential is given more arguments the behaviour is undefined (see 15).
An implementation may accept and use a larger number for fractionDigits than 20. Such implementation should take 9.b.i of the algorithm as a guideline.
Number.prototype.toExponential = function(fractionDigits){
var x = this.[[PrimitiveValue]];
var f = ToInteger(fractionDigits);
if (isNaN(x)) return "NaN";
var s = '';
if (x < 0) {
s = '-';
x = -x;
}
if (x == Infinity) return s+'Infinity';
if (fractionDigits !== undefined && f < 0 || f > 20) throw RangeError;
if (x == 0) {
var f = 0;
var m = new Array(f+1).join('0');
var e = 0;
} else { // x != 0
if (fractionDigits !== undefined) {
var e,n; // 10^f<=n<10^(f+1), st n*10^(e-f)-x is close to 0 as possible. If two such sets, pick largest.
} else { // step 9.b.i
var e,n,f; // st f>=0, 10^f <= n < 10^(f+1), x=n*10^(e-f), f as small as possible. note: n has f+1 digits, not deivislbe by 10 and the least significant digit of n is not necessarily uniquely determined.
}
var m = n+'';
}
if (f!=0) {
var a = m[0];
var b = m.substring(1);
}
if (e == 0) {
var c = "+";
var d = "0";
} else {
if (e > 0) var c = "+";
else {
var c = "-";
e = -e;
}
var d = e+'';
}
m += "e"+c+d;
return s + m;
}