Purpose
TRUNC() returns a numeric value truncated to a given precision.
Syntax
TRUNC (numeric[,precision])
Parameters
| Parameter | Description |
|---|---|
| numeric | The number to truncate. It is of a numeric data type such as NUMBER, FLOAT, BINARY_FLOAT, or BINARY_DOUBLE. |
| precision | The precision. This parameter is optional. The default value is 0. It is of a numeric data type such as NUMBER, FLOAT, BINARY_FLOAT, or BINARY_DOUBLE.
|
Return type
If you do not specify precision, the return type is the same as the data type of numeric. If you specify precision, the return type is NUMBER.
Examples
The following example truncates the number 555.666 for cases where the values of precision are respectively 2.2, -2, and not specified.
obclient> SELECT TRUNC(555.666,2.2),TRUNC(555.666,-2),TRUNC(555.666) FROM DUAL;
+--------------------+-------------------+----------------+
| TRUNC(555.666,2.2) | TRUNC(555.666,-2) | TRUNC(555.666) |
+--------------------+-------------------+----------------+
| 555.66 | 500 | 555 |
+--------------------+-------------------+----------------+
1 row in set