Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

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;