1#include <math.h> 2#include <stdint.h> 3 4float frexpf(float x, int* e) { 5 union { 6 float f; 7 uint32_t i; 8 } y = {x}; 9 int ee = y.i >> 23 & 0xff; 10 11 if (!ee) { 12 if (x) { 13 x = frexpf(x * 0x1p64, e); 14 *e -= 64; 15 } else 16 *e = 0; 17 return x; 18 } else if (ee == 0xff) { 19 return x; 20 } 21 22 *e = ee - 0x7e; 23 y.i &= 0x807ffffful; 24 y.i |= 0x3f000000ul; 25 return y.f; 26} 27