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
| Parameter | Type | Required | Description |
|---|---|---|---|
number | T | Yes | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
number | DECIMAL | Yes | The 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 BIGINT | f2 BIGINT | f3 BIGINT | f4 BIGINT | f5 BIGINT | f6 BIGINT |
|---|---|---|---|---|---|
| 2 | 2 | -3 | -3 | 5 | 3 |