Skip to main content

The "round_to" Function


round_to(value, multiple);
valuerealThe value to round
multiplerealThe number to round to, as a multiple


Rounds to a multiple of the specified number (rather than to the nearest whole) and returns the result. Unlike normal rounding, rounding to fractional values is supported.

Note that this script uses "banker's rounding", meaning if a value is exactly half the multiplier, it will round to the nearest even number.

Also note that the multiplier should always be positive. The value to round can be either positive or negative.


score = round_to(score, 10);