Function to obtain an integer part of a floating-point number.

 

Syntax

function Trunc(x: extended): integer;

 

Parameters and return values

Parameter

Type

Value

x

extended

fractional number from which you need to obtain an integer part only.

 

Function result

Integer part of a number.

 

Example


begin
  mLogScript('Round(12.75) = ' + inttostr(round(12.75)), '');
  mLogScript('Trunc(12.75) = ' + inttostr(trunc(12.75)), '');  
end.


Script work result

[08:57:49] (Log "Trunc"): Round(12.75) = 13

[08:57:49] (Log "Trunc"): Trunc(12.75) = 12
 

See also

IntToStr
mLogScript

Round