The system function MathLib.round rounds a number or expression to a nearest value (for example, to the nearest thousands) and returns the result.
MathLib.round( numericField mathLibNumber in [, powerOf10 mathLibInteger in ]) returns (result mathLibTypeDependentResult)
MathLib.round(numericExpression anyNumericExpression in returns (result mathLibTypeDependentResult)
A numeric overflow occurs at run time if more than 31 digits are used in the calculation and if EGL cannot determine the violation at development time.
You cannot use MathLib.round with the remainder operator (%).
If you do not specify powerOf10, MathLib.round rounds to the number of decimal places in result.
The integer is defined as type INT or the following equivalent: type BIN with length 9 and no decimal places.
In the next example, item balance is rounded to the nearest thousand:
balance = 12345.6789; rounder = 3; balance = MathLib.round(balance, rounder); // The value of balance is now 12000.0000
In the next example, a rounder value of -2 is used to round balance to two decimal places:
balance = 12345.6789; rounder = -2; balance = mathLib.round(balance, rounder); // The value of balance is now 12345.6800
Related concepts
Syntax diagram for EGL functions
Related reference
EGL library MathLib