Name
Round Function
Syntax
Round(expression[,numdecimalplaces])
expressionUse: Required
Data Type: Numeric
Any numeric expression.
numdecimalplacesUse: Optional
Data Type: Long
The number of places to include after the decimal point.
Return Value
The same data type as
expression.
Description
Rounds a given number to a specified number of decimal places.
Rules at a Glance
numdecimalplacescan be any whole number between 0 and 16.Round follows standard rules for rounding:
If the digit in the position to the right of
numdecimalplacesis greater than 5, the digit in thenumdecimalplacesposition is incremented by one.If the digit in the position to the right of
numdecimalplacesis less than 5, the digits to the right ofnumdecimalplacesare dropped.If the digit in the position to the right of
numdecimalplacesis 5 and the digit in thenumdecimalplacesposition is odd, the digit in thenumdecimalplacesposition is incremented by one.If the digit in the position to the right of
numdecimalplacesis 5 and the digit in thenumdecimalplacesposition is even, the digits to the right ofnumdecimalplacesare dropped.
Programming Tips and Gotchas
If expression is a string
representation of a numeric value, Round
converts it to a numeric value before rounding. However, if
expression isn’t a string representation
of a number, Round generates runtime error 13,
“Type mismatch.” The IsNumeric function insures
that expression is a proper numeric
representation before calling Round.
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access