C# 小数点后保留位数

https://zhidao.baidu.com/question/537686608.html

1、num.ToString("#0.00"); //点后面几个0就保留几位

2、num.ToString("f2"); //fN 保留N位,四舍五入,"F","f" 不区分大小写

3、Math.Round(i,2); //不精确,不推荐,例如Math.Round((double)3 / 11, 5);

posted @ 2019-12-02 16:33  剑存古风  阅读(1415)  评论(0编辑  收藏  举报