How to convert a integer to float in Delphi?

Aftershock picture Aftershock · Oct 14, 2010 · Viewed 53.6k times · Source

How to convert a integer to float in Delphi?

E.g int_h:= int_var/1.5* int_var;

Answer

CodesInChaos picture CodesInChaos · Oct 14, 2010

i*1.0 should convert it to a floatingpoint number. Any calculation involving floatingpoint numbers of any type gets implicitly converted to extendend and then implicitly converted to the desired result type on assignment. In contrast to C/C++ all calculations happen in Extended(80 bit float, the internal format of the x87 floatingpoint unit) and are converted back later.

real(i) might work too.