Truncate a decimal number.
1 math.trunc
<math.trunc>
<var | expr /> !
<var | expr /> ?
</math.trunc>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Evar | expr | Object2BigDecimal | Value or expression with decimals. | |||
Evar | expr | object2Integer | Value or expression integer. |
Returns | |
---|---|
Type | Description |
Number | Natural number. |
Exceptions
too many arguments for trunc function
The number of arguments specified is not correct.
Example
Truncate a decimal number.
Copy
<xsql-script name='math_trunc_sample1'> <body> <println><math.trunc>14.23</math.trunc></println> </body> </xsql-script>
The result of truncate the number 14.23, is 14.
Example
Truncate a decimal number, with a scale of two decimals.
Copy
<xsql-script name='math_trunc_sample2'> <body> <println><math.trunc>14.2346<number>2</number></math.trunc></println> </body> </xsql-script>
The result of truncate the number 14.2346, with a sclae of 2 decimals, is 14.23. You can observe how the first argument correspond to the decimal number to truncate and the second to the integer number to use as scale.