📜  C#中的Decimal.Floor()方法

📅  最后修改于: 2021-05-29 15:10:57             🧑  作者: Mango

此方法用于将小数点四舍五入为负无穷大的最接近的整数。

下面的程序说明了Decimal.Floor(Decimal)方法的用法:

范例1:

// C# program to demonstrate the
// Decimal.Floor(Decimal) Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
  
        // Declaring the decimal variable
        Decimal a = 4.01m;
  
        // finding the floor of the Decimal value
        // using floor() method;
        Decimal value = Decimal.Floor(a);
  
        // Display the Floor
        Console.WriteLine("Floor Value is : {0}",
                                          value);
    }
}
输出:
Floor Value is : 4

范例2:

// C# program to demonstrate the
// Decimal.Floor(Decimal) Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
  
        // Declaring the decimal variable
        Decimal a = -5.03m;
  
        // finding the floor of the Decimal value
        // using floor() method;
        Decimal value = Decimal.Floor(a);
  
        // Display the Floor
        Console.WriteLine("Floor Value is : {0}",
                                          value);
    }
}
输出:
Floor Value is : -6

范例3:

// C# program to demonstrate the
// Decimal.Floor(Decimal) Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
  
        // Declaring the decimal variable
        Decimal a = 2.00m;
  
        // finding the floor of 
        // the Decimal value
        // using floor() method;
        Decimal value = Decimal.Floor(a);
  
        // Display the Floor
        Console.WriteLine("Floor Value is : {0}",
                                          value);
    }
}
输出:
Floor Value is : 2