Skip to main content
Version: 1.0.0

trunc

trunc* ( number : number, places : integer) : number

ParameterTypeDescription
numbernumberNumber to be truncated
placesintegerNumber of decimal places used for truncating
ResultnumberNumber with its decimal part truncated to the number of decimal places specified by places

Description

trunc returns number with its decimal part truncated to the number of decimal places specified by places. trunc always truncates toward negative infinity.

If places is positive, number is truncated to places decimal places. If places is negative, number is truncated on the left of the decimal point.

Example

 var vlResult : number
vlResult = trunc(216.897,1) // vlResult gets 216.8
vlResult = trunc(216.897,-1) // vlResult gets 210
vlResult = trunc(-216.897,1) // vlResult gets –216.9
vlResult = trunc(-216.897,-1) // vlResult gets –220

See also

round