Skip to content

MidPointRounding for Math.Round() method in .Net Application

eliza sahoo

Asked Mar 24, 2010, 3:06 AM EDT1 answer
Share
LinkedInX
We all know Math.Round() basically rounds a particular decimal value. But if we look into this method closely it rounds the value to the nearest even value.
For example if we do Math.Round(2.5,0) it will return 2. But we may expect 3 intead of 2. In that case we can use MidPointRounding parameter of
Math.Round() method.
 
Math.Round can also take a parameter known as MidPointRoundingwhich helps us to select the Rounding option. That means whether we want to round towards even number or to the number away from zero.
 
For example, when someone  do the rounding of 8.5 .  MidpointRounding will help to specify whether rounding will be towards the even number (8) or it will be away from zero (9).
 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 1 short reply
    • Hirendra Sisodiya
      0
      great.........
      0