Xojo.Math.Ceil

From Xojo Documentation

Method

Xojo.Math.Ceil(value As Double) As Double

Supported for all project types and targets.

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