Decimal Math.Round(Decimal, Int 32, Midpoint Rounding) 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#
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.
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
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
DecimalThe 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
Argument | decimals is less than 0 or greater than 28. |
Argument | mode is not a valid value of System.MidpointRounding. |
Overflow | The result is outside the range of a System.Decimal. |