I have a strange behavior I'd like to understand. I have the following code:
union floatInt
{
float f;
unsigned int l;
};
floatInt A, B;
A.l = 0xFFA70B56;
B.f = A.f;
std::cout << std::hex << B.l << std::endl;
It's undefined behavior to read from the member of the union that
wasn't most recently written. Many compilers implement, as a
non-standard language extension, the ability to read inactive members
of a union.
Your NaN is being converted from a signalling NaN to a quiet NaN. The upper bit of the fraction, bit 22, changes from a zero to a one.
You might see the same behavior even if you weren't using a union.