Export (0) Print
Expand All

toPrecision Method (JavaScript)

Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.

numObj.toPrecision ([precision])


Required. A Number object.


Optional. Number of significant digits. Must be in the range 1 – 21, inclusive.

For numbers in exponential notation, precision - 1 digits are returned after the decimal point. For numbers in fixed notation, precision significant digits are returned.

If precision is not supplied or is undefined, the toString method is called instead.

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Applies To: Number Object (JavaScript)

Community Additions

© 2014 Microsoft