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. This behavior is slightly different from that of the mround() function in Excel which always rounds away from zero.


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: 2022/11/06 17:10 by dmitry

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki