User Tools

Site Tools


syntax:functions:mround

MRound(number, grain)

Category: Number function


Description

This function rounds a number to the desired multiple (grain).


Arguments

ArgumentTypeDescription
numberNumberThe value, usually fractional, to be rounded.
grainNumberThe multiple to round number to.


Return value type: Number


Remarks

MRound uses "bankers rounding" which rounds a value ending in 5 to the nearest even value.


Examples

mround(5.3, 0.5) //Returns 5.5
mround(10.05, 0.1) //Returns 10.0 (bankers rounding rounds to the closest even value)
mround(10.15, 0.1) //Returns 10.2 (bankers rounding rounds to the closest even value)
mround(20.78, 1) //Returns 21
mround(57, 15) //Returns 60


See also

syntax/functions/mround.txt · Last modified: 2021/09/07 11:53 by craigt