@ROUND

Rounds expression to numDigits.

Syntax

@ROUND (expression, numDigits [, compatibility])
Parameter Description

expression

Single member specification, variable name, or other numeric expression.

numDigits

Single member specification, variable name, or other numeric expression that provides an integer value. If numDigits is 0 or a positive number, expression is rounded to the number of decimal places specified by numDigits. If numDigits is a negative value, expression is rounded to the nearest 10 to the power of the absolute value of numDigits. For example:

@ROUND(1234, -2) = 1200

The default value for numDigits is 0.

compatibility

Optional backward-compatibility setting to select which algorithm you want to use for rounding margin of error.

Possible keyword values:

  • COMPATPREV11121—Original rounding algorithm, in use up until Release 11.1.2.1. The integer part of the number is used to generate the rounding margin of error. Limitation: aggregate values are only accurate up to the 15th decimal place.

    Only some decimal numbers can be represented perfectly in binary. For example, if the value 1234.725 is loaded, it may be represented in binary as 1234.72499999999991. Using the COMPATPREV11121 algorithm to round this number to two decimal places returns 1234.72, though you may prefer 1234.73.

  • COMPATPREV11123—Alternate rounding algorithm, in use between Release 11.1.2.1 and 11.1.2.3, to negate the representational error discussed above. The rounding margin of error was changed for better precision, which in some cases returned different results than the original algorithm.

If unspecified, the default rounding algorithm now matches the standard used by the C-language Round function. The C Round function is a common rounding algorithm, used widely across platforms. It uses a built-in construct of floor and ceiling functions to map a real number to the largest previous or the smallest subsequent integer, respectively, depending on numDigits.

Example

The following example is based on the Sample Basic database:

SET UPDATECALC OFF;
Profit = @ROUND("Profit_%", 1);

This example produces the following report:

                          Market Product 
                   Profit_%                 Profit         
            Jan     Feb     Mar      Jan      Feb      Mar
            ===     ===     ===      ===      ===      === 
Scenario   21.37   19.09   18.46    21.4      19.1    18.5 

See Also