Formats the value of a number to the specified precision.
JSV_numberFormat(expN, expP)
n/a
The numberFormat function returns the string representation of a number formatted to the specified precision.
The numberFormat function uses the following arguments.
Argument | Description |
expN | The number that is to be formatted. |
expP | The precision to which the formatting should occur. |
This function is similar to the round
function, but pads the rounded number with the appropriate number of zeros.
n/a
The following lines of code
var f = 1.0/5.0;
document.write( "The number " + f +
" can be formatted to 2 decimal places and be displayed as " +
JSV_numberFormat(f,2) );
document.write( "The number " + f +
" can be formatted to 4 decimal places and be displayed as " +
JSV_numberFormat(f,4) );
produce
Copyright © 1998-2000 Roaring Fork Software. All rights reserved.