I have the internal representation of a float
stored in a uint32_t
. Suppose we have two of them with those conditions. I want to sum the two floats
represented by the uint32_t
and then store their internal representation inside another uint32_t
. I've been trying a few things but I'm not sure if there is an easy or standard way of doing so. From my point of view, there are two problems:
- Convert the internal representation stored in the
uint32_t
to afloat
(otherwise I wouldn't know how to sum them). - After the sum, store the resulting
float
internal representation in auint32_t
.
I've been looking at functions in C libraries and maybe it could be done with printf
or atof
but I have not managed to resolve it.
Well, I finally used memcpy() to solve it. I am not entirely sure that it is completely reliable but I think it works well.
The number printed is 3.1000 as expected.