DefaultRoundingStrategyRound Method

Returns a decimal rounded to the nearest value of 10^-n.

Definition

Namespace: InnerDrive.Financial
Assembly: InnerDrive.Financial (in InnerDrive.Financial.dll) Version: 5.2.9017.0
C#
public decimal Round(
	decimal value,
	int decimals
)

Parameters

value  Decimal
The value to round to a given number of significant digits.
decimals  Int32
The number of significant digits to round the value.

Return Value

Decimal
The number nearest value with precision equal to decimals. If value is halfway between two numbers, one of which is even and the other odd, then the even number is returned. If the precision of value is less than decimals, then value is returned unchanged.

Implements

IRoundingStrategyRound(Decimal, Int32)

Remarks

The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding. If decimals is zero, this kind of rounding is sometimes called rounding toward zero.

Example

For the default rounding strategy, Round(123.4567, 1) would return 123.4, while Round(-123.4567, 2) would return -123.46.

Exceptions

ArgumentOutOfRangeExceptionThrown when decimals is less than 0 or greater than MaxDigits.

See Also