ceil()
Published Oct 15, 2023
Contribute to Docs
The ceil()
function in Lua’s math library rounds up a given number to the smallest integer that is greater than or equal to the passed value. The given number can be a positive or negative number.
Syntax
math.ceil(x)
x
: The number to be rounded up.
Example
In this example, math.ceil()
is used to round a pair of values.
local num1 = 14.4local num2 = -22.5local ceilNum1 = math.ceil(num1)local ceilNum2 = math.ceil(num2)print(ceilNum1)print(ceilNum2)
This will result in the following output:
15-23
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.