Reading from an inactive member of a union is plain and simply undefined behavior. To read and write the bits of the `float` in a well defined way use `std::memcpy`.
Curiously, it is undefined in C++, whereas well-defined in C: "6.5.2.3 Structure and union members If the member used to read the contents of a union object is not the same as the member last used to store a value in the object, the appropriate part of the object representation of the value is reinterpreted as an object representation in the new type as described in 6.2.6 (a process sometimes called ‘‘type punning’’). This might be a trap representation." Since C++ includes C as a normative reference it would be a good idea to allow it also in C++. memcpy is fine if the compiler optimizes it as an intrinsic, but inefficient in some implementations to copy only a couple of bytes. Best, Ion