cancel
Showing results for 
Search instead for 
Did you mean: 

copy float's binary content into uint32_t

NTaha.1
Associate II

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?

4 REPLIES 4
gbm
Lead III

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.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

the variable declarations is in the first pic

0693W00000Y9aG9QAJ.png

Thanks for the answer, I tried Union too, it's0693W00000Y9bTOQAZ.png the same.