truncate
Table of Contents
Overview
The truncate function returns the input decimal truncated to the specified number of places to the left or right of the decimal point.
Return Type
Syntax
<variable> = <number>.truncate(<digits>);
where,
Parameter | Data type | Description |
<variable> | DECIMAL | Variable that will hold the truncated value. |
<number> | DECIMAL | Variable that holds the input decimal value. |
<digits> | NUMBER | number of digits that need to be truncated. Note:
|
Examples
number = 25.125432 ; info number.truncate(2); // returns 25.12 number = 9789.852 ; info number.truncate(0); // returns 9789 number = 9789.852 ; info number.truncate(-2); // returns 9700