FLOOR scalar function

Returns the largest integer value less than or equal to the argument.

Read syntax diagramSkip visual syntax diagramFLOOR(expression)

The schema is SYSIBM. (The SYSFUN version of the FLOOR function continues to be available.)

expression
An expression that returns a value of any built-in numeric data type.

The result of the function has the same data type and length attribute as the argument except that the scale is 0 if the argument is DECIMAL. For example, an argument with a data type of DECIMAL(5,5) returns DECIMAL(5,0).

The result can be null if the argument can be null or if the argument is not a decimal floating-point number and the database is configured with dft_sqlmathwarn set to YES; the result is the null value if the argument is null.

Notes

  • Results involving DECFLOAT special values: For decimal floating-point values, the special values are treated as follows:
    • FLOOR(NaN) returns NaN.
    • FLOOR(-NaN) returns -NaN.
    • FLOOR(Infinity) returns Infinity.
    • FLOOR(-Infinity) returns -Infinity.
    • FLOOR(sNaN) returns NaN and a warning.
    • FLOOR(-sNaN) returns -NaN and a warning.

Examples

  • Example 1: Use the FLOOR function to truncate any digits to the right of the decimal point.
       SELECT FLOOR(SALARY)
         FROM EMPLOYEE
  • Example 2: Use the FLOOR function on both positive and negative numbers.
       VALUES FLOOR(3.5), FLOOR(3.1),
         FLOOR(-3.1), FLOOR(-3.5)
    This example returns 3., 3., -4., and -4., respectively.