Returns a string representing the Number object in exponential notation
| Method of Number | |
| Implemented in: | JavaScript 1.5 |
| ECMA Version: | ECMA-262 |
A string representing a Number object in exponential notation with one digit before the decimal point, rounded to fractionDigits digits after the decimal point. If the fractionDigits argument is omitted, the number of digits after the decimal point defaults to the number of digits necessary to represent the value uniquely.
If you use the toExponential method for a numeric literal and the numeric literal has no exponent and no decimal point, leave a space before the dot that precedes the method call to prevent the dot from being interpreted as a decimal point.
If a number has more digits that requested by the fractionDigits parameter, the number is rounded to the nearest number represented by fractionDigits digits. See the discussion of rounding in the description of the toFixed method, which also applies to toExponential.
var num=77.1234;
alert("num.toExponential() is " + num.toExponential()); //displays 7.71234e+1
alert("num.toExponential(4) is " + num.toExponential(4)); //displays 7.7123e+1
alert("num.toExponential(2) is " + num.toExponential(2)); //displays 7.71e+1
alert("77.1234.toExponential() is " + 77.1234.toExponential()); //displays 7.71234e+1
alert("77 .toExponential() is " + 77 .toExponential()); //displays 7.7e+1
Page last modified 15:26, 18 Jul 2007 by Diablownik