Returns the rounded value of a numeric expression.

Syntax

ROUND ( num_expression
[ , rounding_factor]);

Notes

  • num_expression must be numeric or must be convertible to numeric.
  • num_expression must be one of these supported data types:
    • INTEGER
    • TINYINT
    • SMALLINT
    • NUMBER
    • FLOAT
    • DOUBLE PRECISION
  • If the data type of num_expression is not a supported type, ROUND returns an error message.
  • The num_expression is rounded to the next higher digit when:
    • The digit before a negative rounding_factor is 5 or greater
    • The digit after a positive rounding_factor is 5 or greater
  • The num_expression is rounded to the next lower digit when:
    • The digit before a negative rounding_factor is 4 or less
    • The digit after a positive rounding_factor is 4 or less
  • rounding_factor is an integer between -32 and +32 inclusive, and indicates the digit position to which you want to round num_expression. The following figure illustrates how the digit positions are numbered. In the figure below, the num_expression is 2953861.8320.
    Figure 1. ROUND digit positions


    • If you do not specify a rounding_factor, the function rounds num_expression to digit 0 (the ones place).
    • To round to the right of the decimal point, specify a positive rounding_factor.
    • To round to the left of the decimal, specify a negative rounding_factor.

Example

This example illustrates four calls to the ROUND function:

-- rounding_factor 2 returns 2953861.83
ROUND ( 2953861.8320, 2 )
  -- rounding_factor -2 returns 2953900.00
ROUND ( 2953861.8320, -2 )
  -- rounding_factor 0 returns 2953862.00
ROUND ( 2953861.8320, 0 )
  -- No rounding_factor argument also returns 2953862.00
ROUND ( 2953861.8320 )

In each case the num_expression is 2953861.8320. In the first call the rounding_factor is 2, in the second call the rounding_factor is -2, in the third call therounding_factor is 0, and in the fourth call no rounding_factor is specified.

Compatibility

Progress extension