1
0

frexpf.c 352 B

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