# floor

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

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

``floor(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

The `floor` function in Julia:

``floor(x)``

returns the nearest integral value of the same type as `x` that is less than or equal to `x`.

``floor(T, x)``

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

The optional arguments `digits` and `base` work as they do for the `round` function.

Here are some examples of how the `floor` function can be used:

1. Basic usage with integers:

``````julia> floor(5)
5

julia> floor(8.9)
8``````

The `floor` function returns the nearest integral value that is less than or equal to the input number.

2. Conversion to a specific type:

``````julia> floor(Int, 5.6)
5

julia> floor(Float32, 7.8)
7.0``````

Using `floor(T, x)`, we can convert the result to a specific type. If the value is not representable, it throws an `InexactError`.

3. Usage with `digits` and `base`:

``````julia> floor(3.14159, digits=3)
3.141

julia> floor(123.456, base=10)
120.0``````

The `digits` argument specifies the number of significant digits to consider, and the `base` argument determines the rounding base.

And that's how you can use the `floor` function in Julia!