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

Stan GershengorenRank #4,252 · 355 reputationPosted Apr 24, 2006, 3:49 PM EDT
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
aboovk5 reputationPosted Apr 24, 2006, 10:35 PM EDT
Thanks for your reply.
Is there any other rounding methods availabe in c#?
Aboo
Alan Williams8 reputationPosted Apr 26, 2006, 1:44 AM EDT