I got confused in a weird instance in C # (. Net) where, in my opinion, rounding in the structure is wrong.
Math.Round(9.995, 2, MidpointRounding.AwayFromZero)
When I round this value, I will return to 9.99. Given that MidpointRounding.AwayFromZero is tuned to this logic, my assumption is that it will be rounded to 10. Example:
Math.Round(9.95, 1, MidpointRounding.AwayFromZero)
Rounds to 10. These results seem to be inconsistent, but can anyone explain why or what I can do to ensure proper rounding?
Thank!
source
share