Method

Xojo.Math.Ceil


Warning

This item was deprecated in version 2020r2. Please use Ceiling as a replacement.

Description

Returns the ceiling of a number by rounding it up to the nearest whole number.

Sample code

Get the ceiling of a number:

Using Xojo.Math

Dim d As Double
d = Ceil(1.234) ' returns 2

Ceil only works to whole numbers so if you want to round a value to a specific number of decimal places, you first have to multiple the number by 10^(number of decimal places), calculate the Ceil and then divide it by the same value to get the number. For example, this example rounds 1.2345 to 1.3:

Using Xojo.Math

Dim d As Double
Const kDecimalPlaces = 1

d = Ceil(1.2345 * (10 ^ kDecimalPlaces)) / (10 ^ kDecimalPlaces) ' d = 1.3

Compatibility

All project types on all supported operating systems.