User Tools

Site Tools


syntax:functions:round

Round(number, dec_places)

Category: Number function


Description

This function rounds a number to dec_places number of decimal digits.


Alternative syntax

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

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


Arguments

ArgumentTypeDescription
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


Remarks

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 is using the latter, as it's the standard way of rounding as described in IEEE Standard 754, section 4. For Excel-type rounding (away from zero) use RoundXL(number, dec_places) function.

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


Examples

round(5.55, 1) //Returns 5.6
round(5.65, 1) //Returns 5.6
round(101.567, 2) //Returns 101.57
round(101.5784, 3) //Returns 101.578
round(92.523, 0) //Returns 93
round(12345, -2) //Returns 12300


See also

syntax/functions/round.txt · Last modified: 2023/02/28 20:13 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki