C#中Math.Round四舍五入的用法详解,

double testd = 3184.39995117187;  
double nd = Math.Round(testd, 2);   // 3184.4  
nd = Math.Round(testd, 2, MidpointRounding.AwayFromZero);// 3184.4  
  
  
nd = Math.Round(3184.367, 2);    //  3184.37  
nd = Math.Round(3184.365, 2);    // 3184.36  
  
  
nd = Math.Round(3184.367, 2, MidpointRounding.AwayFromZero);   //3184.37  
nd = Math.Round(3184.365, 2, MidpointRounding.AwayFromZero);    //3184.37  

你可能感兴趣的:(C#中Math.Round四舍五入的用法详解,)