MathRound Method (Double, Int32, MidpointRounding) |
Rounds a double-precision floating-point value to the specified number of fractional digits. A parameter specifies how to round the value if it is midway between two other numbers.
Namespace: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static double Round(
double value,
int digits,
MidpointRounding mode
)
Parameters
- value
- Type: SystemDouble
A double-precision floating-point number to be rounded. - digits
- Type: SystemInt32
The number of fractional digits in the return value. - mode
- Type: SystemMidpointRounding
Specification for how to round value if it is midway between two other numbers.
Return Value
Type:
DoubleThe number nearest to
value that has a number of fractional digits equal to
digits. If
value has fewer fractional digits than
digits,
value is returned unchanged.
Exceptions Exception | Condition |
---|
ArgumentOutOfRangeException | digits is less than 0 or greater than 15. |
ArgumentException | mode is not a valid value of MidpointRounding. |
See Also