FLOOR

The FLOOR function returns the largest integer value less than or equal to expression.

Read syntax diagramSkip visual syntax diagramFLOOR (expression)
expression
An expression that returns a value of any built-in numeric, character-string, or graphic-string data type. A string argument is cast to double-precision floating point before evaluating the function. For more information about converting strings to double-precision floating point, see DOUBLE_PRECISION or DOUBLE.

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 a decimal number. For example, an argument with a data type of DECIMAL(5,5) will result in DECIMAL(5,0).

If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Note

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) and FLOOR(-sNaN) returns a warning or error.1

Example

  • Use the FLOOR function to truncate any digits to the right of the decimal point.
      SELECT FLOOR(SALARY)
        FROM EMPLOYEE
  • Use FLOOR on both positive and negative numbers.
      SELECT FLOOR( 3.5),
             FLOOR( 3.1),
             FLOOR(-3.1),
             FLOOR(-3.5)
        FROM SYSIBM.SYSDUMMY1
    This example returns:
    3.   3.  -4.  -4.
    respectively.
1 If *YES is specified for the SQL_DECFLOAT_WARNINGS query option, NaN and -NaN are returned respectively with a warning.