Skip to main content

trunc

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

ParameterTypeDescription
numbernumber->Number to be truncated
placesinteger->Number of decimal places used for truncating
Resultnumber<-Number 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