# ceil

``````..  ceil([T,] x, [digits, [base]])

``ceil(x)`` returns the nearest integral value of the same type as ``x``
that is greater than or equal to ``x``.

``ceil(T, x)`` converts the result to type ``T``, throwing an
``InexactError`` if the value is not representable.

``digits`` and ``base`` work as for :func:`round`.``````

## Examples

In the Julia programming language, the function `ceil` is used to round a number up to the nearest integral value.

1. Round up a floating-point number:

``````julia> ceil(3.7)
4.0``````

This example rounds up the floating-point number 3.7 to 4.0.

2. Round up a negative number:

``````julia> ceil(-2.5)
-2.0``````

It rounds up the negative number -2.5 to -2.0.

3. Specify the number of digits:

``````julia> ceil(3.14159, digits=3)
3.142``````

By setting the `digits` argument to 3, it rounds up to the nearest number with three decimal places.

4. Specify the base for rounding:

``````julia> ceil(17, base=5)
20.0``````

Here, the number 17 is rounded up to the nearest multiple of 5.

5. Convert the result to a specific type:
``````julia> ceil(Int, 2.5)
3``````

By providing the type `Int` as the first argument, it returns the rounded-up value as an integer.

Common mistake example:

``````julia> ceil("2.5")
ERROR: MethodError: no method matching ceil(::String)``````

In this example, the function `ceil` is applied to a string instead of a numeric value. The `ceil` function can only be used with numbers, so it's important to pass a valid numeric argument to avoid such errors.