The TRUNC function returns the numeric value that is truncated based on precision.
Syntax
TRUNC (numberic[,precision])
Parameters
| Parameter | Description |
|---|---|
| numeric,precision | The expression of the numeric types: NUMBER, FLOAT, BINARY_FLOAT, and BINARY_DOUBLE. If precision is not an integer, precision is truncated to its integer part. If precision is greater than or equal to 0, numeric is truncated to the number of decimal places specified by precision. If precision is less than 0, numeric is truncated to precision digits to the left of the decimal point, and other data before the decimal point is represented by zero. The default value of precision is 0. |
Return type
If precision is not specified, the return type is the same as the data type of the numeric parameter. If precision is specified, the return type is NUMBER.
Examples
This example shows the results of calculating 5555.66666 under different values of precision.
Execute the following statement:
SELECT TRUNC(5555.66666, 2.1), TRUNC(5555.66666, -2.6), TRUNC(5555.66666) FROM DUAL;
The following query result is returned:
+-----------------------+------------------------+--------------------+
| TRUNC(5555.66666,2.1) | TRUNC(5555.66666,-2.6) | TRUNC(5555.033333) |
+-----------------------+------------------------+--------------------+
| 5555.66 | 5500 | 5555 |
+-----------------------+------------------------+--------------------+