Ceiling Method

Decimal.Ceiling Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

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

public static decimal Ceiling(
	decimal d
)

Parameters

d
Type: System.Decimal
A decimal number.

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.

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

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


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


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft