Specifies how mathematical rounding methods should process a number that is midway between two numbers.
Assembly: mscorlib (in mscorlib.dll)
Use with appropriate overloads of Math.Round to provide more control of the rounding process.
A rounding operation takes an original number with an implicit or specified precision; examines the next digit, which is at that precision plus one; and returns the nearest number with the same precision as the original number. For positive numbers, if the next digit is from 0 through 4, the nearest number is toward negative infinity. If the next digit is from 6 through 9, the nearest number is toward positive infinity. For negative numbers, if the next digit is from 0 through 4, the nearest number is toward positive infinity. If the next digit is from 6 through 9, the nearest number is toward negative infinity.
In the previous cases, the enumeration does not affect the result of the rounding operation. However, if the next digit is 5, which is the midpoint between two possible results, the nearest number is ambiguous. In this case, the enumeration enables you to specify whether the rounding operation returns the nearest number away from zero or the nearest even number.
The following table demonstrates the results of rounding some negative and positive numbers in conjunction with the values of . The precision used to round the numbers is zero, which means the number after the decimal point affects the rounding operation. For example, for the number -2.5, the digit after the decimal point is 5. Because that digit is the midpoint, you can use a value to determine the result of rounding. If is specified, -3 is returned because it is the nearest number away from zero with a precision of zero. If is specified, -2 is returned because it is the nearest even number with a precision of zero.
The following code example demonstrates the Round method in conjunction with the enumeration.