Siebel eScript Language Reference > Methods Reference > Mathematical Methods >

Round Number Method


The Round Number method does the following:

  • If the fractional part is equal to or greater than 0.5, then it rounds the value in the number argument up.
  • If the fractional part is less than 0.5, then it rounds the value in the number argument down.

It rounds a positive number or a negative number to the nearest integer.

It returns the integer that is closest in value to the value that the number argument contains.

This method uses the same argument as the Get Absolute Value method. For more information, see Table 106.

Format

Math.round(number)

Example

The following example uses the Round Number method:

var a = Math.round(123.6);
var b = Math.round(-123.6)
TheApplication().RaiseErrorText(a + "\n" + b)

This example provides the following results:

124
negative 124

Avoiding Precision Loss Due to Rounding

The following example illustrates precision loss due to rounding:

var n = 34.855;
n = n* 100;
var r = Math.round(n)

The value of the n variable is 3485.499999999999995 instead of 3485.5. Rounding this value results in a value of 3485 instead of 3486.

The following example avoids loss of precision due to rounding:

var n = parseFloat(34.855);
n = parseFloat(n1b*100.0);
var r = Math.round(n);

If you multiply or divide a value, and then round that value, then rounding might not be precise. Multiplication and division can cause precision loss.

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