Export (0) Print
Expand All

toExponential Method (Number) (JavaScript)

Represents a number in exponential notation.

numObj. toExponential([fractionDigits])

numObj

Required. A Number object.

fractionDigits

Optional. The number of digits after the decimal point. Must be in the range 0 – 20, inclusive.

Returns a string representation of a number in exponential notation. The string contains one digit before the decimal point, and may contain fractionDigits digits after it.

If fractionDigits is not supplied, the toExponential method returns as many digits necessary to uniquely specify the number.

var num = new Number(123);
var exp = num.toExponential();
document.write(exp);
document.write("<br/>");

num = new Number(123.456);
exp = num.toExponential(5);
document.write(exp);


// Output: 
// 1.23e+2
// 1.23456e+2

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Applies To: Number Object (JavaScript)

Show:
© 2014 Microsoft