I have an array which has data which is mixed in format. It contains both unsigned ints & floats (all stored in a 4 byte data each).
I want to convert each 4 byte data to a float. However, none of the methods worked for me. For example.
union
{
DWORD i;
float f;
} u;
This method doesn't work. Neither does reinterpret_cast to float.
The data I have is like this.
{ 1, 8, 1.00000, -1.000000 }
I have a uint32_t
pointer which points to the memory.
DWORD value = *(uint_pointer)
gives me the 1, 8 correctly and not the others.
Using a typecast float causes 1.00000 & -1.00000 to be recognized correctly but not the other two.
I basically want the result to be
{ 1.00000, 8.00000, 1.00000, -1.00000 }
I looked at SO for all the previous answers but none of them worked reliably hence I am posting this again to get some ideas.
Thanks