Skip to main content
NTaha.1
Associate II
January 31, 2023
Question

copy float's binary content into uint32_t

  • January 31, 2023
  • 4 replies
  • 2351 views

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?

    This topic has been closed for replies.

    4 replies

    gbm
    Super User
    January 31, 2023

    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
    NTaha.1
    NTaha.1Author
    Associate II
    January 31, 2023

    the variable declarations is in the first pic