I recently encountered a weird problem that has to do with the VARIANT struct.
An external application has updated the VARIANT with a float value that conforms to the IEEE 754 standard (using Memory Watch, I verified that the bits are aligned correctly, representing a specific floating point value).
However when accessing the VARIANT using the fltVal member, the resulting float number is entirely different than expected.

The following code seems to have fixed the problem:
Code:
// 'v' is of VARIANT type
unsigned int uiVal = (unsigned int)v.fltVal; 
float fVal = *((float*)&uiVal);
However, I'm not sure as to what has caused this problem and why the code above fixes it. I suspect this has something to do with the union type properties, but I'm not sure.

Any input is appreciated.

Regards,
Zachm