Javascript Reference
Categories: Number

javascript Number toPrecision( )

@March 15, 2008, 1:22 a.m.
toPrecision( )Firefox/Netscape/NN 6 IE 5.5(Win) ECMA 3  



Returns a string containing the number object's value displayed with a fixed number of digits, counting digits to the left and right of the decimal. If you specify a parameter that yields a display with fewer digits to the left of the decimal than the original number, the returned value is displayed in exponential notation. Truncated values are rounded, but based only on the value of the digit immediately to the right of the last displayed digit (i.e., rounding does not cascade).

  • An integer specifying the total number of digits in the returned string.
Returned Value


Powered by Linode.