Click here to Skip to main content
16,003,404 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi friends,

I am using VS 2005,C#,asp.net.
I am using Math.round function to round to 2 decimal points.
Math.round(200.925,2) =200.92
Not rounding to 200.93.
But Math.round(200.935,2) =200.94
Math.round(200.945,2) =200.95
What is the reason for not rounding of 200.925

Regards,
george n
Posted

1 solution

From the documentation
http://msdn.microsoft.com/en-us/library/3s2d3xkk.aspx[^]

If the fractional component of d is halfway between two integers, one of which is even and the other odd, the even number is returned. Note that this method returns a Decimal instead of an integral type

Now you state that Math.round(200.945,2) = 200.95 which would then be wrong according to the documentation. On my system Math.round(200.945,2) = 200.94
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900