システム関数 MathLib.round は、数値または式を、一番近い値 (例えば、千単位) に丸め、結果を戻します。
MathLib.round( numericField mathLibNumber in [, powerOf10 mathLibInteger in ]) returns (result mathLibTypeDependentResult)
MathLib.round(numericExpression anyNumericExpression in returns (result mathLibTypeDependentResult)
計算に 31 を超える桁数が使用され、EGL が開発時に違反を判別できないと、実行時に数値のオーバーフローが発生します。
剰余演算子 (%) とともに MathLib.round を使用することはできません。
powerOf10 を指定しないと、MathLib.round は result の小数点以下の桁数に丸められます。
その整数は、INT 型か、長さが 9 で小数部がない BIN 型と同等と定義されます。
次の例では、balance を 1000 の位の値に丸めます。
balance = 12345.6789; rounder = 3; balance = MathLib.round(balance, rounder); // balance の値は 12000.0000 です
次の例では、rounder 値を -2 にして、balance を小数点以下 2 桁に丸めます。
balance = 12345.6789; rounder = -2; balance = mathLib.round(balance, rounder); // balance の値は 12345.6800 です
関連概念
EGL 関数の構文図
関連リファレンス
EGL ライブラリー MathLib