TRUNCATE()
All functions > MATH > TRUNCATE()
Returns the integer part of a number by discarding the fractional part.
Signatures
Truncate
Returns: Integer result after truncation
TRUNCATE(number: T) → BIGINT sql
| Parameter | Type | Required | Description |
|---|---|---|---|
number | T | Yes | The number to truncate |
With:
T: Custom types: FLOAT | DOUBLE | DECIMAL
Signature notes:
- Rounds toward zero (discards fractional part)
- Different from FLOOR for negative numbers:
TRUNCATE(-2.9) = -2vsFLOOR(-2.9) = -3 - Returns NULL if the input is NULL
Examples
FeatureQL
SELECT
-- Positive truncates toward zero
f1 := TRUNCATE(2.1e0),
-- Removes decimal part
f2 := TRUNCATE(2.9e0),
-- Negative truncates toward zero
f3 := TRUNCATE(-2.1e0),
-- Different from FLOOR
f4 := TRUNCATE(-2.9e0),
-- Pi truncated
f5 := TRUNCATE(3.14159e0)
;Result
| f1 BIGINT | f2 BIGINT | f3 BIGINT | f4 BIGINT | f5 BIGINT |
|---|---|---|---|---|
| 2 | 2 | -2 | -2 | 3 |
On this page