FLOOR()

All functions > MATH > FLOOR()

Returns the largest integer less than or equal to the input.

Signatures

Floor of a floating-point number

Returns: Largest integer ≤ input

FLOOR(number: T) → BIGINT
sql
ParameterTypeRequiredDescription
numberTYesThe number to round down

With:

  • T : Custom types: FLOAT | DOUBLE

Signature notes:

  • Always rounds toward negative infinity
  • FLOAT and DOUBLE return BIGINT. DECIMAL(p, s) returns DECIMAL(p - s + min(s, 1), 0). A value outside the result range fails when the query runs
  • Returns NULL if the input is NULL
  • Opposite of CEIL for negative numbers

Floor of a decimal

Returns: DECIMAL(p - s + min(s, 1), 0), the largest decimal at that scale that is ≤ the input

FLOOR(number: DECIMAL) → DECIMAL
sql
ParameterTypeRequiredDescription
numberDECIMALYesThe decimal to round down

Examples

FeatureQL
RETURN
    -- Positive rounds down
    f1 := FLOOR(2.1e0),
    -- Another positive
    f2 := FLOOR(2.9e0),
    -- Negative rounds away from zero
    f3 := FLOOR(-2.1e0),
    -- Negative further from zero
    f4 := FLOOR(-2.9e0),
    -- Exact integer unchanged
    f5 := FLOOR(5.0e0),
    -- Pi rounds down to 3
    f6 := FLOOR(3.14159e0)
;
Result
f1 BIGINTf2 BIGINTf3 BIGINTf4 BIGINTf5 BIGINTf6 BIGINT
22-3-353