User Tools

Site Tools


syntax:functions:roundxl

This is an old revision of the document!


RoundXL(number, dec_places)

Category: Number function


Description

This function rounds number to dec_places decimal digits using the Excel rounding logic.

Excel rounding logic rounds a decimal value of 5 or greater up to the next nearest value (towards positive infinity) and 4 or less down to the next nearest value (towards negative infinity).


Arguments

ArgumentTypeDescription
numberNumberThe value, usually fractional, to be rounded.
dec_placesNumber (positive, >=0)The number of decimal places to round number to.


Return value type: Number


Remarks

There exists two types of rounding, in general - "Rounding away from zero" (a.k.a. symmetric rounding) and "Rounding to the nearest even number" (a.k.a. banker's rounding). This function uses the former (symmetric rounding), which is also the type of rounding used in Excel. For standard rounding (banker's rounding) use Round(number, dec_places).

Using a dec_places value of "0" rounds to the nearest whole number.


Examples

roundxl(5.55, 1) //Returns 5.6
roundxl(5.65, 1) //Returns 5.7
roundxl(10.434, 2) //Returns 10.43
roundxl(20.5456, 3) //Returns 20.546


See also

syntax/functions/roundxl.1631028047.txt.gz · Last modified: 2021/09/07 11:20 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki