美文网首页
C#中Math.Round四舍五入的用法详解,

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

作者: 贰丶萌 | 来源:发表于2017-12-14 17:59 被阅读0次
    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四舍五入的用法详解,

          本文链接:https://www.haomeiwen.com/subject/ltukixtx.html