DecimalMath.Round(Decimal, Int32, MidpointRounding) Method

Rounds a decimal value to a specified number of fractional digits. A parameter specifies how to round the value if it is midway between two other numbers.

Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
C#
public static decimal Round(
	decimal value,
	int decimals,
	MidpointRounding mode
)

Parameters

value  Decimal
A decimal number to be rounded.
decimals  Int32
The number of decimal places in the return value.
mode  MidpointRounding
Specification for how to round value if it is midway between two other numbers.

Return Value

Decimal
The number nearest to value that contains a number of fractional digits equal to decimals. If the number of fractional digits in value is less than decimals, value is returned unchanged.

Exceptions

ArgumentOutOfRangeException decimals is less than 0 or greater than 28.
ArgumentException mode is not a valid value of System.MidpointRounding.
OverflowException The result is outside the range of a System.Decimal.

See Also