Decimal.Ceiling Method (System)

Switch View :
ScriptFree
.NET Framework Class Library
Decimal.Ceiling Method

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

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

Visual Basic
Public Shared Function Ceiling ( _
	d As Decimal _
) As Decimal
C#
public static decimal Ceiling(
	decimal d
)
Visual C++
public:
static Decimal Ceiling(
	Decimal d
)
F#
static member Ceiling : 
        d:decimal -> decimal 

Parameters

d
Type: System.Decimal
A decimal number.

Return Value

Type: System.Decimal
The smallest integral value that is greater than or equal to the d parameter. Note that this method returns a Decimal instead of 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.

Visual Basic

Dim values() As Decimal = {12.6d, 12.1d, 9.5d, 8.16d, .1d, -1.1d, -3.9d}
For Each value As Decimal In values
   Console.WriteLine("{0} -> {1}", value, _
                     Decimal.Ceiling(value))
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      


C#

decimal[] values = {12.6m, 12.1m, 9.5m, 8.16m, .1m, -1.1m, -3.9m};
foreach (decimal value in values)
   Console.WriteLine("{0} -> {1}", 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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also

Reference