User Tools

Site Tools


RoundXL(number, dec_places)

Category: Number function


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).

Alternative syntax

The 2nd argument in this function is optional. If omitted, it's assumed to be 0.

RoundXL(number)  //The same as RoundXL(number, 0)


numberNumberThe value, usually fractional, to be rounded.
dec_placesNumber (from -9 to 28)The number of decimal places to round number to.

Return value type: Number


There exist 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.


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
roundxl(12345, -2) //Returns 12300

See also

syntax/functions/roundxl.txt · Last modified: 2023/02/28 20:14 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki