MariaDB FLOOR() Function

In MariaDB, FLOOR() is a built-in number function that returns the largest integer value less than or equal to a given number.

If you want to return the smallest integer value greater than or equal to a specified number, use CEIL() or CEILING().

If you want to round a number to a specified number of decimal places, use ROUND().

If you want to truncate decimal places by digits, use TRUNCATE().

MariaDB FLOOR() Syntax

Here is the syntax of the MariaDB FLOOR() function:

FLOOR(number)

Parameters

number

Required. A number.

If you provide the wrong number of parameters, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'FLOOR'.

Return value

The MariaDB FLOOR() function returns the largest integer value less than or equal to a given number.

If the parameter number is NULL, the FLOOR() function will return NULL.

MariaDB FLOOR() Examples

This statement shows the basic usage of the MariaDB EXP() function:

SELECT
    FLOOR(123.123),
    FLOOR(123.789),
    FLOOR(123),
    FLOOR(-123.123),
    FLOOR(-123.789),
    FLOOR(-123),
    FLOOR(-100),
    FLOOR(NULL)\G

Output:

 FLOOR(123.123): 123
 FLOOR(123.789): 123
     FLOOR(123): 123
FLOOR(-123.123): -124
FLOOR(-123.789): -124
    FLOOR(-123): -123
    FLOOR(-100): -100
    FLOOR(NULL): NULL

Conclusion

In MariaDB, FLOOR() is a built-in number function that returns the largest integer value less than or equal to a given number.