ceil

Returns the given number rounded up to the nearest integer.

Syntax:

GML Code Example

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:

GML Code Example

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:

GML Code Example

val = ceil( 3.4 );

This will set val to 4.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here