Starr Duskk
asked on
Decimals not rounding properly
I have a decimal field that holds a percentage value, such as 37.5 or 62.5
I convert that to an integer to remove the decimals. However, it isn't rounding up and down properly when it is .5
37.5 rounds up to 38.
62.5 rounds down to 62.
87.5 rounds up to 88.
Everything else works as expected.
Anyone know why this is and how to fix it?
thanks!
I convert that to an integer to remove the decimals. However, it isn't rounding up and down properly when it is .5
37.5 rounds up to 38.
62.5 rounds down to 62.
87.5 rounds up to 88.
Everything else works as expected.
Anyone know why this is and how to fix it?
thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
edited my first comment.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I should give it_saige some points since he was likely formulating his tests and response when I found the solution to be to use MidpointRounding.AwayFromZ ero.
ASKER
Complete answer and explanation why it doesn't work.