Hello.
¿How to convert from long int to float?
We can use type cast to convert long int to float. For example:
volatile long int l_val=5;
volatile float f_result,f_val=1.23;
f_result=(float)l_val/f_val;
In above code " l_val " computes as float.
Hello,
You might want to see if you get approximately the correct value when I_val is initialised with a value that exceeds the 16-bit numeric range, e.g. long int I_val = 123456L; Of course, the conversion to float will usually result in some loss of precision, maybe with accuracy limited to about 5 digits.
Regards,
Mac
Juan, I invite you to mark the best answer as correct, this way other people experiencing the same problem can identify the solution.
If the answers here have not helped, let us know!
Regards!
We can use type cast to convert long int to float. For example:
volatile long int l_val=5;
volatile float f_result,f_val=1.23;
f_result=(float)l_val/f_val;
In above code " l_val " computes as float.