How to add your knowledge

roundToNearest()

    Table of contents
    1. 1. Synopsis
    2. 2. Syntax
    3. 3. Example 1
    4. 4. Example 2
    5. 5. Example 3
    6. 6. Example 4

    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