Skip to content

Int ​

While Int appears to imitate Trunc, in that it returns the integer portion of a decimal number X, its behaviour is slightly different, as the result from an Int function is a data type from the floating-point family, rather than an integer type.

Please review Trunc for more information.

Also refer to Frac to return the fractional part of a decimal number.

Declaration: Function Int(const X: Extended): Extended

A few examples are shown below.

pascal
Procedure OnMapEvent(var Value:variant);
var bNumber : extended;
begin
  Value :=  Int(5566.234589);        // returns 5566
  Value :=  Int(-8112.46);           // returns -8112

  bNumber :=  Int(4567.234589);      // returns 4567
  LogInfo(FloatToStr(bNumber));
  bNumber :=  Int(-5232.46);         // returns -5232
  LogInfo(FloatToStr(bNumber));
  bNumber :=  Int(1234.56);          // returns 1234
  LogInfo(FloatToStr(bNumber));

end;