Round Function

Syntax

Round(expression[, numdecimalplaces])

Round(number,precision)


expression

Use: Required

Data Type: Numeric Expression

Any numeric expression.


numdecimalplaces

Use: 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

  • numdecimalplaces can be any whole number between and 16.

  • Round follows standard rules for rounding. That is, if the digit in the position to the right of numdecimalplaces is 6 or greater, the digit in the numdecimalplaces position is incremented by 1; if 5, it becomes the nearest even number; otherwise, the digits to the right of numdecimalplaces are dropped.

Programming Tips and Gotchas

  • Round with a numdecimalplaces set to 2 is equivalent to Format (expression, "#.##").

  • 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.

  • If expression contains fewer decimal places than numdecimalplaces, Round doesn't pad the return value with trailing zeros.

See Also

Fix Function, Int Function
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.63.138