The TRUNC function returns a numeric expression truncated to a specified number of digits to the right of the decimal point. If the specified number of digits is positive and longer than the digits after the decimal point, 0 is added after the fraction digits. If the specified number of digits is negative and larger than or equal to the digits before the decimal point, 0 is returned. When a numeric expression is truncated, the trailing digits are simply dropped off. The return value is not rounded in any way.
This function returns the same datatype as the passed parameter.
$ROUND(numeric_expression [, n] )
Required. Any expression that returns a numeric expression.
Optional. An integer n is an integer indicating the number of digits to the right of the decimal. The default is 0.
> select latitude, trunc(latitude) from countries with opt=none; LATITUDE TRUNC(COUNTRIES.LATITUDE) -------------------------------- -------------------------------- 42.500000 42.000000 24.000000 24.000000 33.000000 33.000000 17.049999 17.000000 18.209999 18.000000 41.000000 41.000000 40.000000 40.000000
Note that floating point values cannot represent ever value, and the values shown below are as close as floating point values can represent.
> select latitude, trunc(latitude, 1) from countries with opt=none; LATITUDE TRUNC(COUNTRIES.LATITUDE,1) -------------------------------- -------------------------------- 42.500000 42.500000 24.000000 24.000000 33.000000 33.000000 17.049999 17.000000 18.209999 18.200001 41.000000 41.000000 40.000000 40.000000
See also: