Freigeben über


Decimal.Floor-Methode

Rundet eine angegebene Decimal-Zahl auf die nächste Ganzzahl in Richtung minus unendlich.

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

Syntax

'Declaration
Public Shared Function Floor ( _
    d As Decimal _
) As Decimal
'Usage
Dim d As Decimal
Dim returnValue As Decimal

returnValue = Decimal.Floor(d)
public static decimal Floor (
    decimal d
)
public:
static Decimal Floor (
    Decimal d
)
public static Decimal Floor (
    Decimal d
)
public static function Floor (
    d : decimal
) : decimal

Parameter

Rückgabewert

Wenn d einen Teil mit Bruchzahlen enthält, die nächste ganze Decimal-Zahl in Richtung minus unendlich, die kleiner als d ist. – oder – Wenn d keinen Teil mit Bruchzahlen aufweist, wird d unverändert zurückgegeben.

Beispiel

Das folgende Codebeispiel veranschaulicht die Verwendung von Floor.

Class PiggyBank
    Public ReadOnly Property Dollars() As Decimal
        Get
            Return [Decimal].Floor(MyFortune)
        End Get
    End Property

    Protected MyFortune As Decimal

    Public Sub AddPenny()
        MyFortune += 0.01D
    End Sub
End Class
class PiggyBank {
    public decimal Dollars {
        get {
            return Decimal.Floor(MyFortune);
        }
    }

    protected decimal MyFortune;

    public void AddPenny() {
        MyFortune += .01m;
    }
}
   public ref class PiggyBank
   {
   public:
      Decimal Dollars()
      {
         return Decimal::Floor( MyFortune );
      }

      void AddPenny()
      {
         MyFortune = Decimal::Add(MyFortune, (Decimal).01);
      }

   protected:
      Decimal MyFortune;
   };

}
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);
    }
}

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

Decimal-Struktur
Decimal-Member
System-Namespace
Round
Truncate