Not a bug, but rather a feature. I think it is called a banker's round. Even whole numbers are rounded down and odd whole numbers are rounded up (from .5). Wiki link
Sub Main()
Console.WriteLine(Math.Round(4.5))
Console.WriteLine(Math.Round(5.5))
Console.WriteLine(Math.Round(4.5, MidpointRounding.AwayFromZero))
Console.WriteLine(Math.Round(5.5, MidpointRounding.AwayFromZero))
Console.ReadLine()
End Sub
Results:
4
6
5
6
Midpoint values and rounding conventions
Rounding involves converting a numeric value with a specified precision to the nearest value with less precision. For example, you can use the Round(Double) method to round a value of 3.4 to 3.0, and the Round(Double, Int32) method to round a value of 3.579 to 3.58.
In a midpoint value, the value after the least significant digit in the result is precisely half way between two numbers. For example, 3.47500 is a midpoint value if it is to be rounded two decimal places, and 7.500 is a midpoint value if it is to be rounded to an integer. In these cases, the nearest value can't be easily identified without a rounding convention.
The Round method supports two rounding conventions for handling midpoint values:
Rounding away from zero
Midpoint values are rounded to the next number away from zero. For example, 3.75 rounds to 3.8, 3.85 rounds to 3.9, -3.75 rounds to -3.8, and -3.85 rounds to -3.9. This form of rounding is represented by the MidpointRounding.AwayFromZero enumeration member.
Rounding away from zero is the most widely known form of rounding. Rounding to nearest, or banker's rounding
Midpoint values are rounded to the nearest even number. For example, both 3.75 and 3.85 round to 3.8, and both -3.75 and -3.85 round to -3.8. This form of rounding is represented by the MidpointRounding.ToEven enumeration member.
Rounding to nearest is the standard form of rounding used in financial and statistical operations. It conforms to IEEE Standard 754, section 4. When used in multiple rounding operations, it reduces the rounding error that is caused by consistently rounding midpoint values in a single direction. In some cases, this rounding error can be significant.
10
u/smokeajay Apr 12 '13
Not a bug, but rather a feature. I think it is called a banker's round. Even whole numbers are rounded down and odd whole numbers are rounded up (from .5). Wiki link