Reference · Math

ceil

signature
ceil(num | dec) -> num | dec

What it does

The smallest whole number not below the argument: 2.1 gives 3, -2.1 gives -2. An int or a float gives an int; a decimal gives a decimal with no decimals.

Examples

print(ceil(2.1), ceil(-2.1), ceil(3), ceil(2.0))print(ceil(2.1m), ceil(-2.1m))print(ceil(10 / 3))
output
3 -2 3 23 -24

Edge cases

print(ceil(-0.5), ceil(0.0001))print(type_of(ceil(2.1)), type_of(ceil(2.1m)))print(ceil(1e16), type_of(ceil(1e16)), ceil(float("nan")))print(ceil(9007199254740995 / 2), ceil(-7 / 2))
output
0 1int dec10000000000000000 int NaN4503599627370498 -3

Errors

A string, null or a boolean is a runtime error, not an error value.

this one fails
print(ceil(null))
output
line 1: `ceil` expects a number as argument 1, got null

Chaining

Pages for a list, a rate per started unit:

let items = 23print(items / 10 | ceil)print([0.2, 1.5] | map(ceil))
output
3[1, 2]

See also

floor, round, int, abs

Thread
8Useful? Like it, or add to its thread below.

Thread 0 posts

On ceil(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo