Decimal.Floor() Method in C#
This method is used to round the decimal to the closest integer toward negative infinity.
Syntax: public static decimal Floor (decimal d);
Parameter:
d: This parameter specifies the decimal which will be rounded off.Return Value: If d has a fractional part, the next whole Decimal number toward negative infinity that is less than d or d doesn’t have a fractional part, d is returned unchanged. Note that the method returns an integral value of type Decimal.
Below programs illustrate the use of Decimal.Floor(Decimal) Method:
Example 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
Example 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
Example 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
Recommended Posts:
- Difference between Method Overriding and Method Hiding in C#
- Decimal.Add() Method in C#
- Extension Method in C#
- C# | Math.Min() Method
- C# | CopyTo() Method
- C# | Uri.GetHashCode() Method
- C# | Dictionary.Add() Method
- C# | Math.Max() Method
- C# | Math.Abs() Method | Set - 1
- C# | Math.Exp() Method
- Method Hiding in C#
- C# | Trim() Method
- C# | Math.Abs() Method | Set - 2
- C# | PadRight() Method
- C# | Method Overriding
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



