c# Compact framework Math.Round up problem

169 Views Asked by At

I am using VS2008 c# , windows mobile 6.5, so I have to use the .Net Compact Framework, the problem is:

When Math.Round(66.05,1) the result is 66 when the correc value should be 66.1 what can I do ? how should I use the round() function

Thanks

1

There are 1 best solutions below

3
Marco Elizondo On

You should use the overloaded static Math.Round method which takes two arguments:

decimal x = Math.Round(2.5555, 2);      // x == 2.56

You can read more here.

The issue with this is that the Mathf.Round method by default use "ToEven convention" There is an example using MidpointRounding.AwayFromZero that will give you the result you expect