-1

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

KillemAll
  • 633
  • 1
  • 10
  • 25

1 Answers1

-2

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

Marco Elizondo
  • 552
  • 3
  • 9
  • try with my example,.. it goes down, no up,... thats the problem – KillemAll Apr 12 '20 at 02:33
  • Oh I understand, well the Mathf.Round method by default use "ToEven convention" https://learn.microsoft.com/en-us/dotnet/api/system.midpointrounding?view=netframework-4.8#System_MidpointRounding_ToEven There is an example using MidpointRounding.AwayFromZero that will give you the result you expect. – Marco Elizondo Apr 12 '20 at 02:55
  • 1
    You should update your answer with the `.ToEven` answer. You would get the accept on that rather than downvotes. – Enigmativity Apr 12 '20 at 03:13