Bookshelf Home | Contents | Index | PDF |
Siebel eScript Language Reference > Siebel eScript Commands > The Math Object > Math.round() MethodThis method rounds a number to its nearest integer. SyntaxReturnsThe integer closest in value to number. UsageThe number parameter is rounded up if its fractional part is equal to or greater than 0.5 and is rounded down if less than 0.5. Both positive and negative numbers are rounded to the nearest integer. ExampleThis code fragment yields the values 124 and -124. var a = Math.round(123.6); NOTE: Rounding may not be precise if you multiply or divide a value and then round it. Multiplication and division leads to precision loss. ExampleThis code fragment illustrates precision loss due to multiplication. var n = 34.855; The value of n is 3485.499999999999995 instead of 3485.5. When rounded this results in 3485 instead of 3486. ExampleThis code fragment provides a workaround for the loss of precision due to multiplication. var n = parseFloat(34.855); See AlsoClib.modf() Method |
Siebel eScript Language Reference |