This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I have a simple code that reads some data from UART and converts it to float, and I've encountered a problem:
uint32_t temp1; float vel; vel = (float) temp1; // ERROR: the hexadecimal data in temp1 and vel is not the same !! memcpy((void*)&vel, (void*)&temp1, 2); // OK!
How come casting to float is not working as expected?
A floating point number is stored in IEEE 754 format, so the hex won't match a unsigned integer.
https://en.wikipedia.org/wiki/IEEE_754
Regards
Lori