Table of Contents

Search

  1. Preface
  2. Understanding Data Types and Field Properties
  3. Designing Processes
  4. Using and Displaying Data
  5. Designing Guides
  6. Designing Process Objects
  7. Designing Service Connectors
  8. Using App Connections
  9. System Services, Listeners and Connectors
  10. Designing Human Tasks

Design

Design

trunc (Numbers)

trunc (Numbers)

Truncates numbers to a specific digit based on the number of decimal places specified by the precision.

Syntax

util:trunc(
arg
,
precision
)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument that you want to truncate. You can enter any valid expression that evaluates to a numeric data type.
precision
Optional
Can be a positive or negative integer. You can enter any valid expression that evaluates to an integer. The integer specifies the number of digits to truncate.
If
precision
is a positive integer, trunc returns
arg
with the number of decimal places specified by
precision
. If
precision
is a negative integer, trunc changes the specified digits to the left of the decimal point to zeros. If you omit the
precision
argument, trunc truncates the decimal portion of
arg
and returns an integer.
All trailing zeros after the decimal point in an argument will be truncated. For example, the following expression returns 2345.7535 as the result:
util:trunc(2345.75350000, 6)
If a number contains more than 16-digits after the decimal point, the result returns an exponential value due to an XQuery limitation.
For example, the following expression returns 1.234567812345679E7 as the result:
util:trunc(12345678.12345678901234567890, 15)
If you pass a decimal
precision
value, the
arg
is rounded to the nearest integer before evaluating the expression.

Return Value

Numeric or integer value based on the parameters provided in the function.

Examples

The following expressions truncate the values in the PRICE column:
util:trunc(PRICE, 3)
PRICE
RETURN VALUE
12.9995
12.999
-18.8652  
-18.865
56.9563
56.956
15.9928
15.992
util:trunc(PRICE, -1)
PRICE
RETURN VALUE
12.99
10
-187.86  
-180
56.95
50
1235.99
1230
util:trunc(PRICE )
PRICE
RETURN VALUE
12.99
12
-18.99  
-18
56.95
56
15.99
15

0 COMMENTS

We’d like to hear from you!