Siebel eScript Language Reference > Methods Reference > Conversion Methods >

Convert Number to Precision Method


The Convert Number to Precision method converts a number to a number that includes a number of significant digits. It returns the converted number contained in the numberVar variable, expressed to the number of significant digits that you specify in the len argument.

This method allows you to express a number at a desired length. For example, the result of a scientific calculation might only require accuracy to a specific number of significant digits.

This method does one of the following depending on if the value that the len argument contains is:

  • Less than the number of significant decimal places that exist in the value that the numberVar variable contains. It does one of the following:
    • If the number is five or greater, then it rounds the result up.
    • If the number is less than five, then it rounds the result down.
  • Greater than the number of significant decimal places that exist in the value that the numberVar variable contains. It pads the extra digits with zeroes and adds a decimal point, if necessary.

This method uses the same argument as the Convert Number to Exponential Notation method. For more information, see Table 87.

Format

numberVar.toPrecision(len)

Example

The following example uses the Convert Number to Precision method:

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

Siebel eScript Language Reference Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.