ROUND( ) Function

Returns a numeric expression rounded to a specified number of decimal places.

ROUND(nExpression, nDecimalPlaces)

Return Values

Numeric

Parameters

  • nExpression
    Specifies the numeric expression whose value is to be rounded.

  • nDecimalPlaces
    Specifies the number of decimal places nExpression is rounded to.

    If nDecimalPlaces is negative, ROUND( ) returns a whole number containing zeros equal in number to nDecimalPlaces to the left of the decimal point. For example, if nDecimalPlaces is –2, the first and second digits to the left of the decimal point in the value are 0.

Remarks

The value ROUND( ) returns has the same number of decimal places as nDecimalPlaces. ROUND( ) ignores the number of decimal places specified by SET DECIMALS.

Example

SET DECIMALS TO 4
SET FIXED ON     && Fix decimal display
CLEAR

? ROUND(1234.1962, 3) && Displays 1234.1960
? ROUND(1234.1962, 2) && Displays 1234.2000
? ROUND(1234.1962, 0) && Displays 1234.0000
? ROUND(1234.1962, -1)  && Displays 1230.0000
? ROUND(1234.1962, -2)  && Displays 1200.0000
? ROUND(1234.1962, -3)  && Displays 1000.0000

SET FIXED OFF  && Restore start up defaults
SET DECIMALS TO 2

See Also

CEILING( ) | FLOOR( ) | INT( ) | SET DECIMALS | SET FIXED Command