Home c# Rounding rules
Reply: 0

c# Rounding rules

user1006 Published in April 24, 2018, 6:35 am

This question already has an answer here:

  • Why does System.MidpointRounding.AwayFromZero not round up in this instance? 5 answers

I am running into a weird instance in C#(.net) where I believe the rounding is incorrect in the framework.

Math.Round(9.995, 2, MidpointRounding.AwayFromZero)

When I round this value, I get back 9.99. With the MidpointRounding.AwayFromZero set to this logic, my assumption is that it would round up to 10. Case in point:

Math.Round(9.95, 1, MidpointRounding.AwayFromZero)

Rounds to 10. It seems these results are inconsistent, but can anyone explain why or what I can do to help ensure proper rounding is applied?


You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.330107 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO