ceil

Returns the given number rounded up to the nearest integer.

Syntax:

ceil(val);


Argument Description
x The number to change.


Returns: Integer


Description

This function takes any real number and rounds it up to the nearest integer. Care should be taken with this function as one common mistake is to use it round up a random value and expect it always to be greater than 1, ie:

int = ceil(random(5));


Now, you would expect this code to always give an integer between 1 and 5, but this may not always be the case as there is a very small possibility that the random function will return 0, and rounding up 0 still gives you 0. This is a remote possibility but should be taken into account when using this function.


Example:

val = ceil( 3.4 );

This will set val to 4.


Back: Real Number Functions
Next: max
© Copyright YoYo Games Ltd. 2018 All Rights Reserved