roundToNearest()

Synopsis

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.

Syntax

roundToNearest ( n As Number, _
                 i As Number ) As Number 
Argument Type Description
n Number The input number .
i Number The increment to round to.

Example 1

Intent >roundToNearest(5.73, 0.25) 
--> 5.75 

Example 2

Intent >roundToNearest(-0.37, 0.1) 
--> -0.4 

Example 3

Intent >roundToNearest(376.9, 10) 
--> 380.0 

Example 4

Intent >roundToNearest(385, 10) 
--> 380.0 
Compare this with roundInc(385, 10) which returns 390.0