"For developers", "Server scripts", "Functions description", "Mathematical", "Round".
Rounding a floating-point number.
Rounding uses Banker's algorithm when half of the value causes rounding to an even number.
•12.4 rounds to 12;
•12.5 rounds to 12;
•12.6 rounds to 13.
function Round(x: extended): integer;
Parameter |
Type |
Value |
---|---|---|
x |
extended |
fractional number that you need to round. |
Integer value.
begin
mLogScript('Round(12.4) = ' + inttostr(round(12.4)), '');
mLogScript('Round(12.5) = ' + inttostr(round(12.5)), '');
mLogScript('Round(12.6) = ' + inttostr(round(12.6)), '');
end.
[09:03:22] (Log "Round"): Round(12.4) = 12
[09:03:22] (Log "Round"): Round(12.5) = 12
[09:03:22] (Log "Round"): Round(12.6) = 13