Skip to main content
Version: 21 R3

Trunc

Trunc ( number : Real ; places : Integer ) : Real

ParameterTypeDescription
numberReal→Number to be truncated
placesInteger→Number of decimal places used for truncating
Function resultReal←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.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​

The following example illustrates how Trunc works with different arguments. Each line assigns a number to the vlResult variable. The comments describe the results:

 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

Properties​

Command number95
Thread safeyes