1
Answer

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

Ask a question
eliza sahoo

eliza sahoo

14y
6.6k
1
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).
 

Answers (1)