Uses round() to round a number n to the nearest increment of i. If the given number is equidistant between two increments the function rounds towards the nearest even increment.
roundToNearest ( n As Number, _ i As Number ) As Number
Argument | Type | Description |
---|---|---|
n | Number | The input number . |
i | Number | The increment to round to. |
Intent >roundToNearest(5.73, 0.25) --> 5.75
Intent >roundToNearest(-0.37, 0.1) --> -0.4
Intent >roundToNearest(376.9, 10) --> 380.0
Intent >roundToNearest(385, 10) --> 380.0Compare this with roundInc(385, 10) which returns 390.0