DelphiFAQ Home Search:
General :: Programming :: Delphi
General Delphi related information.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

Cast a floating point number (e.g. real) to an integer

There are a couple of methods to do this conversion.. the results will vary:

var
   i: integer;
   r: real;
 begin
   r := 34.56;
   i := trunc(r);  {i = 34}  { First Method }
   i := round(r);  {i = 35}  { Second Method }
 end;
 

Generated 8:01:34 on Sep 26, 2018