Skip to main content

Number.Round

Returns the rounded number. The number of digits and rounding mode can be specified.

Syntax

Number.Round(
number as number,
optional digits as number,
optional roundingMode as RoundingMode.Type
) as number

Remarks

Returns the result of rounding number to the nearest number. If number is null, Number.Round returns null.

By default, number is rounded to the nearest integer, and ties are broken by rounding to the nearest even number (using RoundingMode.ToEven, also known as "banker's rounding").

However, these defaults can be overridden via the following optional parameters.

  • digits: Causes number to be rounded to the specified number of decimal digits.
  • roundingMode: Overrides the default tie-breaking behavior when number is at the midpoint between two potential rounded values (refer to RoundingMode.Type for possible values).

Examples

Example #1

Round 1.234 to the nearest integer.

Number.Round(1.234)

Result:

1

Example #2

Round 1.56 to the nearest integer.

Number.Round(1.56)

Result:

2

Example #3

Round 1.2345 to two decimal places.

Number.Round(1.2345, 2)

Result:

1.23

Example #4

Round 1.2345 to three decimal places (Rounding up).

Number.Round(1.2345, 3, RoundingMode.Up)

Result:

1.235

Example #5

Round 1.2345 to three decimal places (Rounding down).

Number.Round(1.2345, 3, RoundingMode.Down)

Result:

1.234

Category

Number.Rounding