Ceil

From Xojo Documentation

Global Method

Ceil(value as Double) As Double

Supported for all project types and targets.


Global Method

Ceil(value as Currency) As Currency

Supported for all project types and targets.

Returns the value specified rounded up to the nearest whole number.

Usage

result = Ceil (value)

Part Description
result The ceiling of value.
value The value you want the ceiling of.

Notes

The result of this function is a Double or Currency, but it will always contain a whole number.

Sample Code

This code uses the Ceil function to return ceiling of a number.

Var d As Double
d = Ceil(1.234) // returns 2

Because Ceil will always return a whole number, to round a decimal value to a certain number of places, you must first multiple the number by 10^(the number of decimal places to which you wish to round) then take the value returned by Ceil of that number and divide it by 10^(the number of decimal places to which you wish to round). In this code, the value 1.2345 is being rounded to two decimal places:

Var d As Double
d = Ceil(1.234 * 100) / 100

See Also

Xojo.Math.Ceil, Floor, Round functions.