我想用数学来做。圆的函数


当前回答

你可能需要检查的一件事是数学的舍入机制。轮:

http://msdn.microsoft.com/en-us/library/system.midpointrounding.aspx

除此之外,我推荐数学。Round(inputnumber, numberOfPlaces)接近*100/100,因为它更干净。

其他回答

Math.Floor(123456.646 * 100) / 100 会返回123456.64吗

您应该能够使用Math指定要舍入的位数。轮(YourNumber, 2)

你可以在这里阅读更多。

就我个人而言,我从来没有四舍五入过。让它尽可能坚定,因为舍入在CS中是一个转移注意力的东西。但您确实希望为用户格式化数据,为此,我发现string.Format("{0:0.00}", number)是一种很好的方法。

这是为了在c#中四舍五入到小数点后2位:

label8.Text = valor_cuota .ToString("N2") ;

在VB。NET:

 Imports System.Math
 round(label8.text,2)
  public double RoundDown(double number, int decimalPlaces)
        {
            return Math.Floor(number * Math.Pow(10, decimalPlaces)) / Math.Pow(10, decimalPlaces);
        }