mathLib.round() システム関数は、式の値を、指定された 10 の累乗 (例えば、千の位) に丸め、結果を戻します。
EGL は、丸めポイントの右側の桁に 5 を追加してから、その桁とそれより低い桁からゼロまでのすべての桁を設定することで丸めを行います。
mathLib.round(
numericVariable DECIMAL | SMALLFLOAT | FLOAT in,
powerOf10 INT in)
returns (result DECIMAL | SMALLFLOAT | FLOAT)
最初の例では、変数 balance を 1000 の位に丸めます。
balance FLOAT = 12345.6789;
rounder INT = 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.68 になりました