Export (0) Print
Expand All

Decimal.Floor Method

Rounds a specified Decimal number to the closest integer toward negative infinity.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static decimal Floor (
	decimal d
)
public static Decimal Floor (
	Decimal d
)
public static function Floor (
	d : decimal
) : decimal

Parameters

d

A Decimal.

Return Value

If d has a fractional part, the next whole Decimal number toward negative infinity that is less than d. -or- If d doesn't have a fractional part, d is returned unchanged.

The following code sample illustrates the use of Floor.

class PiggyBank {
    public decimal Dollars {
        get {
            return Decimal.Floor(MyFortune);
        }
    }

    protected decimal MyFortune;

    public void AddPenny() {
        MyFortune += .01m;
    }
}

class PiggyBank
{
    /** @property 
     */
    public System.Decimal get_Dollars()
    {
        return System.Decimal.Floor(myFortune);
    } //get_Dollars

    protected System.Decimal myFortune;

    public void AddPenny()
    {
        myFortune.Add(myFortune, System.Convert.ToDecimal(0.01));
    } //AddPenny
} //PiggyBank

class PiggyBank {
    public function get Dollars() : Decimal {
        return Decimal.Floor(MyFortune);
    }

    protected var MyFortune : Decimal;

    public function AddPenny() {
        MyFortune = Decimal.Add(MyFortune, 0.01);
    }
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft