Returns the smallest integral value that is greater than or equal to the specified double-precision floating-point number.

Examples

Note

The C# examples in this article run in the Try.NET inline code runner and playground. Select the Run button to run an example in an interactive window. Once you execute the code, you can modify it and run the modified code by selecting Run again. The modified code either runs in the interactive window or, if compilation fails, the interactive window displays all C# compiler error messages.

Remarks

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

Ceiling(Decimal)Ceiling(Decimal)Ceiling(Decimal)Ceiling(Decimal)

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

Remarks

The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding toward positive infinity. In other words, if d is positive, the presence of any fractional component causes d to be rounded to the next highest integer. If d is negative, the rounding operation causes any fractional component of d to be discarded. The operation of this method differs from the Floor(Decimal) method, which supports rounding toward negative infinity.

Parameters

Returns

The smallest integral value that is greater than or equal to a. If a is equal to NaN, NegativeInfinity, or PositiveInfinity, that value is returned. Note that this method returns a Double 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. In other words, if a is positive, the presence of any fractional component causes a to be rounded to the next highest integer. If a is negative, the rounding operation causes any fractional component of a to be discarded. The operation of this method differs from the Floor(Double) method, which supports rounding toward negative infinity.

Starting with Visual Basic 15.8, the performance of Double-to-integer conversion is optimized if you pass the value returned by the Ceiling method to the any of the integral conversion functions, or if the Double value returned by Ceiling is automatically converted to an integer with Option Strict set to Off. This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. The following example illustrates such optimized conversions: