Truncates the value to the specified number of places. This function does not round the value.
JSV_truncate(expN, expD)
n/a
The truncate function returns the value of a number truncated to the specified number of places.
The truncate function uses the following arguments.
Argument | Description |
expN | The number to be truncated. |
expD | The specified number of places to truncate to. |
For more information on this topic, see the article Significant Digits by Aaron Weiss.
n/a
The following lines of code
var f = 1.0/3.0;
document.write( "The number " + f +
" can be truncated to 3 decimal places and be displayed as " +
JSV_truncate(f,3) );
var f = 1.0/8.0;
document.write( "The number " + f +
" can be truncated to 2 decimal places and be displayed as " +
JSV_truncate(f,2) );
produce
Copyright © 1998-2000 Roaring Fork Software. All rights reserved.