How to convert a integer to float in Delphi?
E.g int_h:= int_var/1.5* int_var;
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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With