Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a integer to float in Delphi?

Tags:

delphi

pascal

How to convert a integer to float in Delphi?

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

like image 529
Aftershock Avatar asked Oct 14 '10 14:10

Aftershock


People also ask

Can you convert int to float in C?

Just Make the number variable int to float. int total=0, number=0; float percentage=0.0; percentage=((float)number/total)*100; printf("%. 2f", percentage);


1 Answers

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.

like image 97
CodesInChaos Avatar answered Sep 24 '22 16:09

CodesInChaos