RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Int Function

Returns the integer part of a real number.

Pascal
function Int(const X: Extended): Extended;
C++
Extended Int(const Extended X);

System

In Delphi code, Int returns the integer part of X; that is, X rounded toward zero. X is a real-type expression.  

Delphi Examples: 

 

{
Click the button to display the integer part of any positive or
negative real number.
}
procedure TForm1.Button1Click(Sender: TObject);
var 
  R: Real;
begin
  R := StrToFloat(Edit1.Text);     { 123.456 }
  R := Int(R);                     { 123.0 }
  Edit2.Text := FloatToStr(R);
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!