TRUNC Function

Truncates a numeric value to a specified length.

Category: Truncation
Returned data type: DOUBLE

Syntax

Arguments

expression

specifies any valid expression that evaluates to a numeric value.

Data type DOUBLE
See <sql-expression>
FedSQL Expressions

length-expression

specifies any valid expression that evaluates to a numeric value.

Range 3–8
Data type DOUBLE
See <sql-expression>
FedSQL Expressions

Details

The TRUNC function truncates a full-length numeric expression (stored as a DOUBLE) to a smaller number of bytes, as specified in length-expression and pads the truncated bytes with 0s. The truncation and subsequent expansion duplicate the effect of storing numbers in less than full length and then reading them.

Example

The following statements illustrate the TRUNC function:
Statements
Results
select trunc(3.1,3);
select trunc(3.1,4);
select trunc(3.1,5);
select trunc(3.1,6);
select trunc(3.1,7);
select trunc(3.1,8);
3.099609375
3.0999984741
3.099999994
3.1
3.1
3.1
Last updated: February 23, 2017