Hi,
In c# when i perform the Round function it yields results in an unexpeted way.
Can anyone please advise me on this?
Math.Round(0.5); // Result is: 0 But the exptedt is 1
Math.Round(4.5); // Result is: 4 But the exptedt is 5
Math.Round(3.5); // Result is: 4 This is OK
Aboo
Alan WilliamsPosted Apr 26, 2006, 5:44 AM
aboovkPosted Apr 25, 2006, 2:35 AM
Thanks for your reply.
Is there any other rounding methods availabe in c#?
Aboo
Stan GershengorenPosted Apr 24, 2006, 7:49 PM
I looked at the help file for Math.Round and here's what I found
Return Value
The whole number nearest parameter d. If d is halfway between two whole numbers, one of which by definition is even and the other odd, then the even number is returned.
Remarks
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.
Hope this helps