Siebel eScript Language Reference > Siebel eScript Commands > Conversion Methods >
toPrecision() Method
This function returns a number converted to a specified number of significant digits. Syntax
numberVar.toPrecision(len)
|
|
len |
The number of significant digits to which the number contained in variable numberVar is to be converted |
Returns
This function returns the number contained in variable numberVar, expressed to len significant digits. If len is less than the number of significant digits of numberVar, then the function applies standard rounding (round up for 5 or greater, else round down) and expression in scientific notation, if necessary. If len is greater than the number of significant decimal places of numberVar, then the function pads the extra digits with zeroes and adds a decimal point, if necessary. Usage
This function allows you to express numbers at a desired length; for example, the result of a scientific calculation may only justify accuracy to a specific number of significant digits. Example
The following uses of toPrecision() yield the results shown. var anumber = 123.45 var a6 = anumber.toPrecision(6) //returns 123.450 var a4 = anumber.toPrecision(4) //returns 123.5 var a2 = anumber.toPrecision(2) //returns 1.2e+2
See Also
toExponential() Method toFixed() Method
|