C# 计算百分比

时间:2019-01-21 14:25:06   收藏:0   阅读:452
            //计算比率
            decimal A =(decimal) 200.20; 
            decimal B = (decimal)1000.20; 

            decimal t = decimal.Parse((A/B).ToString("0.000")) ; //保留3位小数
            //
            var  t1 = Math.Round(t, 2);  //四舍五入,精确2位

            var t2 = t1 * 100;  //乘以100     x100结果%

 

      var t3 = Math.Floor(Math.Round(decimal.Parse((0 / 100).ToString("0.000")), 2) * 100);

 

 

原文:https://www.cnblogs.com/enych/p/10298396.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!