Decimal.Ceiling(Decimal) 메서드

정의

지정된 10진수보다 크거나 같은 최소 정수 값을 반환합니다.

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

매개 변수

d
Decimal

10진수입니다.

반환

Decimal

d 매개 변수보다 크거나 같은 최소 정수 값입니다. 이 메서드는 정수 계열 형식이 아니라 Decimal을 반환합니다.

예제

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

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 다음으로 가장 높은 정수로 반올림됩니다. d가 음수이면 반올림 연산을 수행하면 의 소수 부분이 d 모두 삭제됩니다. 이 메서드의 연산은 Floor 음의 무한대로 반올림을 지원하는 메서드와 다릅니다.

적용 대상

추가 정보