# Rounding off Decimal

Posted by Raj.Trivedi under C# on 11/17/2014 | Points: 10 | Views : 519 | Status : [Member] [MVP] | Replies : 1
Hello friends

I am performing calculations

and i get results as

1230.4896

or

7896.5236

What i want is if the value after decimal is less than .50XX then it should be converted to the lesser whole number as in above case it should get value as 1230 and if the value after is greater than or equal to .50XX then it should get converted to 7897

Any reference will be appreciated

Regard's
Raj.Trivedi
"Sharing is Caring" 0 Basically you give the Math.Round method three parameters.The value you want to round.The number of decimals you want to keep after the value.An optional parameter you can invoke to use AwayFromZero rounding. Without it, '1.5' rounds to '1' instead of '2'.Sample code:`var roundedA = Math.Round(1.1, 0); // Output: 1var roundedB = Math.Round(1.5, 0, MidpointRounding.AwayFromZero); // Output: 2var roundedC = Math.Round(1.9, 0); // Output: 2` You need MidpointRounding.AwayFromZero is you want a .5 value to be rounded up. Unfortunately this isn't the default behavior for Math.Round().Mark This Response as Answer -- Chandu http://www.dotnetfunda.com/images/dnfmvp.gifRaj.Trivedi, if this helps please login to Mark As Answer. | Alert Moderator