s_frexpf.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* s_frexpf.c -- float version of s_frexp.c.
  2. * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
  3. */
  4. /*
  5. * ====================================================
  6. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  7. *
  8. * Developed at SunPro, a Sun Microsystems, Inc. business.
  9. * Permission to use, copy, modify, and distribute this
  10. * software is freely granted, provided that this notice
  11. * is preserved.
  12. * ====================================================
  13. */
  14. #include "cdefs-compat.h"
  15. //__FBSDID("$FreeBSD: src/lib/msun/src/s_frexpf.c,v 1.10 2008/02/22 02:30:35 das Exp $");
  16. #include <openlibm_math.h>
  17. #include "math_private.h"
  18. static const float
  19. two25 = 3.3554432000e+07; /* 0x4c000000 */
  20. DLLEXPORT float
  21. frexpf(float x, int *eptr)
  22. {
  23. int32_t hx,ix;
  24. GET_FLOAT_WORD(hx,x);
  25. ix = 0x7fffffff&hx;
  26. *eptr = 0;
  27. if(ix>=0x7f800000||(ix==0)) return x; /* 0,inf,nan */
  28. if (ix<0x00800000) { /* subnormal */
  29. x *= two25;
  30. GET_FLOAT_WORD(hx,x);
  31. ix = hx&0x7fffffff;
  32. *eptr = -25;
  33. }
  34. *eptr += (ix>>23)-126;
  35. hx = (hx&0x807fffff)|0x3f000000;
  36. SET_FLOAT_WORD(x,hx);
  37. return x;
  38. }