Decimal.Floor(Decimal) Decimal.Floor(Decimal) Decimal.Floor(Decimal) Decimal.Floor(Decimal) Method

定義

指定した Decimal 数を、負の無限大方向の近似整数に丸めます。Rounds a specified Decimal number to the closest integer toward negative infinity.

public:
 static System::Decimal Floor(System::Decimal d);
public static decimal Floor (decimal d);
static member Floor : decimal -> decimal
Public Shared Function Floor (d As Decimal) As Decimal

パラメーター

d
Decimal Decimal Decimal Decimal

丸める値。The value to round.

戻り値

d に小数部がある場合は、負の無限大方向の d より小さい、次の Decimal 整数。If d has a fractional part, the next whole Decimal number toward negative infinity that is less than d.

または-or- d に小数部がない場合は、d が未変更のまま返されます。If d doesn't have a fractional part, d is returned unchanged. このメソッドは、Decimal 型の整数値を返すことに注意してください。Note that the method returns an integral value of type Decimal.

次の例を示しています、Floorメソッドとの比較、Ceilingメソッド。The following example illustrates the Floor method and contrasts it with the Ceiling method.

using System;

public class Example
{
   public static void Main()
   {
      decimal[] values = {12.6m, 12.1m, 9.5m, 8.16m, .1m, -.1m,  -1.1m, 
                          -1.9m, -3.9m};
      Console.WriteLine("{0,-8} {1,10} {2,10}\n", 
                        "Value", "Ceiling", "Floor");
      foreach (decimal value in values)
      Console.WriteLine("{0,-8} {1,10} {2,10}", value,
                        Decimal.Ceiling(value), Decimal.Floor(value));

   }
}
// The example displays the following output:
//       Value       Ceiling      Floor
//       
//       12.6             13         12
//       12.1             13         12
//       9.5              10          9
//       8.16              9          8
//       0.1               1          0
//       -0.1              0         -1
//       -1.1             -1         -2
//       -1.9             -1         -2
//       -3.9             -3         -4
Module Example
   Public Sub Main()
      Dim values() As Decimal = {12.6d, 12.1d, 9.5d, 8.16d, .1d, -.1d,  
                                 -1.1d, -1.9d, -3.9d}
      Console.WriteLine("{0,-8} {1,10} {2,10}", 
                        "Value", "Ceiling", "Floor")
      Console.WriteLine()
      For Each value As Decimal In values
      Console.WriteLine("{0,-8} {1,10} {2,10}", value,
                        Decimal.Ceiling(value), Decimal.Floor(value))
      Next                                     
   End Sub
End Module
' The example displays the following output:
'       Value       Ceiling      Floor
'       
'       12.6             13         12
'       12.1             13         12
'       9.5              10          9
'       8.16              9          8
'       0.1               1          0
'       -0.1              0         -1
'       -1.1             -1         -2
'       -1.9             -1         -2
'       -3.9             -3         -4      

注釈

このメソッドの動作では、IEEE Standard 754、セクション 4 に従います。The behavior of this method follows IEEE Standard 754, Section 4. この種の丸め処理を行うには、負の無限大に丸めるも呼び出されます。This kind of rounding is sometimes called rounding toward negative infinity. つまり場合、dが正の値、小数部が切り捨てられます。In other words, if d is positive, any fractional component is truncated. 場合dが負の場合、小数部が存在すると、その小さな整数に丸められます。If d is negative, the presence of any fractional component causes it to be rounded to the smaller integer. このメソッドの操作とは異なります、Ceilingメソッドは、正の無限大方向に丸め処理をサポートしています。The operation of this method differs from the Ceiling method, which supports rounding toward positive infinity.

適用対象

こちらもご覧ください