Share via


Decimal.Ceiling Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Returns the smallest integral value greater than or equal to the specified decimal number.

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

Syntax

'Declaration
Public Shared Function Ceiling ( _
    d As Decimal _
) As Decimal
public static decimal Ceiling(
    decimal d
)

Parameters

Return Value

Type: System.Decimal
The smallest integral value greater than or equal to the d parameter. Note that this method returns a Decimal rather than an integral type.

Remarks

The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding toward positive infinity.

Examples

The following example uses the Ceiling method to round an array of Decimal values.

Dim values() As Decimal = {12.6d, 12.1d, 9.5d, 8.16d, .1d, -1.1d, -3.9d}
For Each value As Decimal In values
   outputBlock.Text += String.Format("{0} -> {1}", value, _ 
                                     Decimal.Ceiling(value)) + vbCrLf
Next                                           
' The example displays the following output: 
'       12.6 -> 13
'       12.1 -> 13
'       9.5 -> 10
'       8.16 -> 9
'       0.1 -> 1
'       -1.1 -> -1
'       -3.9 -> -3
decimal[] values = {12.6m, 12.1m, 9.5m, 8.16m, .1m, -1.1m, -3.9m};
foreach (decimal value in values)
   outputBlock.Text += String.Format("{0} -> {1}\n", value, 
                                     Decimal.Ceiling(value));
// The example displays the following output:
//       12.6 -> 13
//       12.1 -> 13
//       9.5 -> 10
//       8.16 -> 9
//       0.1 -> 1
//       -1.1 -> -1
//       -3.9 -> -3

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.