FLOOR
Description
The FLOOR function is used to return the largest integer less than or equal to a given numeric expression (expr). Additionally, it can retain a specified number of decimal places (d) as needed. This function works correctly for various numeric input types, including float, double, decimal, tinyint, smallint, int, and bigint.
Parameter Description
- expr: The numeric expression to be processed, which can be of type float, double, decimal, tinyint, smallint, int, or bigint.
- d (optional): The parameter specifying the number of decimal places to retain, of type int. Negative values are supported, and the default value is 0.
Return Result
The return type is the same as the input expr type. If expr is of type decimal, the return result will be adjusted according to the specified scale value.
Usage Example
- Calculate the largest integer result of -0.1:
- Calculate the maximum integer result of integer 5:
- Calculate the maximum integer result of 5123.123 rounded to one decimal place:
- Calculate the maximum integer result of 5123.123 rounded to the nearest tenth:
- For decimal type, the result retains two decimal places:
- For the tinyint type, calculate the maximum integer result:
- For bigint type, the result retains two decimal places: