copy float's binary content into uint32_t
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-01-31 1: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-01-31 1:27 AM
the variable declarations is in the first pic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-01-31 1:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-01-31 4:33 AM
Thanks for the answer, I tried Union too, it's the same.
