Skip to main content

Round

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

Synopsis

Round(expression[,numdecimalplaces])

Arguments

expression The numeric expression being rounded.
numdecimalplaces Optional — Number indicating how many places to the right of the decimal are included in the rounding. If omitted, expression rounded to an integer is returned.

Description

The Round function always rounds the number 5 up. Leading and trailing zeros are deleted.

Round returns expression rounded to:

  • An integer if the numdecimalplaces argument is omitted, or specified as 0, the empty string (""), or a negative number.

  • The specified number of decimal places (excluding trailing zeros). A fractional value for numdecimalplaces is truncated to an integer.

  • The actual number of decimal places (excluding trailing zeros) if the numdecimalplaces argument is greater than or equal to the actual number of decimal places

Examples

The following example uses the Round function to round a number to three decimal places:

Dim MyVar, pi
pi = 3.14159
MyVar = Round(pi,3) ' MyVar contains 3.142.
Println MyVar

See Also

FeedbackOpens in a new tab