conv_bitcast_i2f.c (539B)
1 /* Bitcast the other direction: reinterpret an int's bits as a float via a 2 * union (FMOV s,w — GPR->FP move, no conversion). volatile defeats folding. 3 * 4 * bits 0x42280000 is the IEEE-754 encoding of 42.0f. Reinterpreting and 5 * truncating yields exactly 42. */ 6 union fb { 7 unsigned int u; 8 float f; 9 }; 10 int test_main(void) { 11 volatile unsigned int src = 0x42280000u; /* bits of 42.0f */ 12 union fb x; 13 x.u = src; /* reinterpret as float, fmov s,w */ 14 float val = x.f; /* 42.0f */ 15 return (int)val; /* fcvtzs -> 42 */ 16 }