A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/c-sharp/decimal-floor-method-in-c-sharp/ below:

Decimal.Floor() Method in C# - GeeksforGeeks

Decimal.Floor() Method in C#

Last Updated : 29 Jan, 2019

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: csharp
// 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);
    }
}
Output:
Floor Value is : 4
Example 2: csharp
// 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);
    }
}
Output:
Floor Value is : -6
Example 3: csharp
// 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);
    }
}
Output:
Floor Value is : 2


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4