Question.3
A developer stores a float in a union, then overwrites it with an integer, then reads the float back:
union { float f; uint32_t u; } data; data.f = 3.14f; data.u = 0x00000001; printf("%f", data.f);
What does this print?
Select Answer
3.140000 — the float value is preserved
1.000000 — the integer 1 is interpreted as float 1.0
A very small number (approximately 1.4e-45) — the bit pattern 0x00000001 is reinterpreted as IEEE 754 float
Undefined behavior — reading a different member than the last one written