Math.Round not rounding up correctly to 2 decimal points

Viewed 1402

I am trying to calculate this:

xx = 95
yy = 45

Math.Round(((xx/ 60) * yy) / 2, 2, MidpointRounding.AwayFromZero);

result should be 35.625 which is rounded to 35.63

but the result I am getting is 35.62,

What am I missing? why is it ignoring the third decimal to round up to 35.63?

3 Answers

Its right and the division is right. your Math result is 35.6249999999 which is rounded to 35.625 or 35.62. In real math you can't round twice so whether you round to 36.625 or 36.62 (5) won't up (2) since it was originally 4 (35.6249999999). hope I explained it right for you.

Related