Round
The Round()
function rounds a number.
Rounding a number can be done according to different strategies when it comes to the mid-point cases (like x.5).
WEM supports the Banker's Rounding strategy as default option because of its statistical superiority and standard use in financial and statistical operations.
From Runtime 4.2 an optional strategy parameter is added to this function. It allows 2 keywords, ToEven (which is default) and AwayFromZero, (new option) that can be set as optional 3rd parameter in the expression if the AwayFromZero strategy is the desired Rounding feature for your application.
Mind, this only applies to the Mid-Point values: the middle of the spectrum, where a decision needs to be made which way to go. So if you expect 3.85 to be rounded to 3.9 (away from zero), you need to use the AwayFromZero in the expression - the default ToEven will result in 3.8 (Banker's).
Read this wiki page about rounding strategies.
This function is NOT SQL compatible. For more information about SQL compatibility, see our documentation.
Returns a number that is rounded to an integral number or a number of fractional digits.
Returns Invalid expression
if one of the parameter values is not a valid number.
Syntax
Parameters
number
numeric
☑️
a number
digits
numeric
the number of fractional digits number
is rounded.
strategy
keyword
ToEven
(default) or AwayFromZero
(Runtime 4.2 only!)
Examples
Round(5.499)
5
Round(5.501)
6
Round(3.85, 1)
3.8
Round(5.489, 2)
5.49
Round(5.499, 2)
5.50
Round(3.85, 1)
3.8
Round(3.85, 1, ToEven
)
3.8 in Runtime 4.2 invalid expression in older runtimes
Round(3.85, 1, AwayFromZero
)
3.9 in Runtime 4.2 invalid expression in older runtimes
Last updated