In C#, the result of Math.Round(2.5)
is 2.
It is supposed to be 3, isn\'t it? Why is it 2 instead in C#?
This post has the answer you are looking for:
http://weblogs.asp.net/sfurman/archive/2003/03/07/3537.aspx
Basically this is what it says:
Return Value
The number nearest value with precision equal to digits. 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 digits, then value is returned unchanged.
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 digits is zero, this kind of rounding is sometimes called rounding toward zero.