¿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;
In above code " l_val " computes as float.
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.
conversion from int to float is exact provided integer can fit FP mantissa. For single precision float, with its 24bit mantissa, no precision is lost converting long int's in the range -16777215 to +16777215.
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!
This answer was given in a service request of freescale.
Retrieving data ...