Round

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

Syntax
      Round(expression, [decimal_places])

Key
   expression    The numeric expression to be rounded.

  decimal_places The number of decimal places to round to.
                 default=0 (which will return an integer).

The Round() function utilizes bankers rounding. When the last significant digit is a 5, it will round to the nearest even number. To instead follow the traditional rule of always rounding a 5 UP add a very small value such as + 0.000001

The Round() function may be used in VBA or in an SQL query.

Examples

Dim intDemo as Integer
intDemo = Round (123.64)
'returns 123
intDemo = Round (123.64, 1)
'returns 123.6
intDemo = Round (2.225, 2)
'returns 2.22
intDemo = Round (2.225 + 0.000001, 2)
'returns 2.23

“I, on the other hand, am a fully-rounded human being, with a degree from the University of Life, a diploma from the School of Hard Knocks, and three gold stars from the Kindergarten of Getting the Shit Kicked Out of Me” ~ Rowan Atkinson (Blackadder 4)

Related:

Int - Return the integer portion of a number (negative numbers round down)
Fix - Return the integer portion of a number (negative numbers round up)
Rounding in Access - Allen Browne


© Copyright SS64.com 1999-2014
Some rights reserved