decimalPlaces
Truncates or rounds to the number of decimal places specified
Prototype
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" function decimalPlaces ( x : numeric, nplaces [1] : integer, round [1] : logical ) return_val : numeric
Arguments
xAn array of any dimensionality.
nplacesA scalar integer equal to the number of places to truncate.
roundA scalar logical. True = round, False = truncate.
Description
Note: there is a bug in this function in versions 5.0.0 and earlier that causes it not to work with negative numbers. See the known bugs list for a fix.
Truncates or rounds to the number of decimal places specified.
Note: If it for printing or placing with a string for say plots, it is better to use the sprintf function.
See Also
Examples
Example 1
x = 12.345678
xRound = decimalPlaces(x,2,True)
; xRound = 12.35