2023-01-31 12:58 AM
Hello,
I am trying to copy the content of a float variable with memcpy into uint32_t variable. unfortunately the binary content changes after copying. it should be 0xfff00000, like in the float variable. Does anyone know why this happens and how can I solve the problem?
2023-01-31 01:24 AM
No one may know why it happens unless you show your code with variable declarations and memcpy call.
It is usually easier to use unions for such tasks.
Oh, you put your source code in an image - not a good practice if you want help. float value shown is incorrect, uint32 seems to be the correct float bit pattern.
2023-01-31 01:27 AM
the variable declarations is in the first pic
2023-01-31 01:42 AM
2023-01-31 04:33 AM
Thanks for the answer, I tried Union too, it's the same.