s_logbf.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* s_logbf.c -- float version of s_logb.c.
  2. * Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].
  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_logbf.c,v 1.9 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.355443200e+07; /* 0x4c000000 */
  20. DLLEXPORT float
  21. logbf(float x)
  22. {
  23. int32_t ix;
  24. GET_FLOAT_WORD(ix,x);
  25. ix &= 0x7fffffff; /* high |x| */
  26. if(ix==0) return (float)-1.0/fabsf(x);
  27. if(ix>=0x7f800000) return x*x;
  28. if(ix<0x00800000) {
  29. x *= two25; /* convert subnormal x to normal */
  30. GET_FLOAT_WORD(ix,x);
  31. ix &= 0x7fffffff;
  32. return (float) ((ix>>23)-127-25);
  33. } else
  34. return (float) ((ix>>23)-127);
  35. }