This method is useful for rounding and formatting number values. This is especially helpful when presenting tables of financial data which needs to be justified and padded to the same number of digits after the decimal point.

The argument value indicates the precision or decimal places of accuracy to the right of the decimal point character. If the argument is undefined, then zero is assumed and the value will be presented as an integer.

This method may be useful for performing truncations from floating point to integer value. The output of this method may also be more precise when a large number of integer digits are required to present the number. According to the ECMA standard, the alternative `toString()` method loses some accuracy for numbers having 19 digits for example.

Prev | Home | Next |

Number.toExponential() | Up | Number.toLocaleString() |

JavaScript Programmer's Reference, Cliff WoottonWrox Press (www.wrox.com)Join the Wrox JavaScript forum at p2p.wrox.comPlease report problems to support@wrox.com© 2001 Wrox Press. All Rights Reserved. Terms and conditions. |