Decimal.Floor(Decimal) 메서드

정의

지정된 Decimal 수를 음의 무한대에 가장 가까운 정수로 반올림합니다.

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

d에 소수 부분이 있으면 다음 정수 Decimald보다 작은 음의 무한대로 반올림됩니다.

또는

d에 소수 부분이 없으면 d는 변경되지 않은 상태로 반환됩니다. 메서드는 형식 Decimal의 정수 값을 반환합니다.

예제

다음 예제에서는 Floor 메서드와 메서드를 Ceiling 대조합니다.

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 표준 754, 섹션 4를 따릅니다. 이러한 종류의 반올림을 음의 무한대로 반올림이라고도 합니다. 즉, 가 d 양수이면 소수 부분이 잘립니다. d가 음수이면 소수 구성 요소가 있으면 더 작은 정수로 반올림됩니다. 이 메서드의 연산은 Ceiling 양의 무한대로 반올림을 지원하는 메서드와 다릅니다.

적용 대상

추가 정보