e_atanhf.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* e_atanhf.c -- float version of e_atanh.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/e_atanhf.c,v 1.7 2008/02/22 02:30:34 das Exp $");
  16. #include <openlibm_math.h>
  17. #include "math_private.h"
  18. static const float one = 1.0, huge = 1e30;
  19. static const float zero = 0.0;
  20. OLM_DLLEXPORT float
  21. __ieee754_atanhf(float x)
  22. {
  23. float t;
  24. int32_t hx,ix;
  25. GET_FLOAT_WORD(hx,x);
  26. ix = hx&0x7fffffff;
  27. if (ix>0x3f800000) /* |x|>1 */
  28. return (x-x)/(x-x);
  29. if(ix==0x3f800000)
  30. return x/zero;
  31. if(ix<0x31800000&&(huge+x)>zero) return x; /* x<2**-28 */
  32. SET_FLOAT_WORD(x,ix);
  33. if(ix<0x3f000000) { /* x < 0.5 */
  34. t = x+x;
  35. t = (float)0.5*log1pf(t+t*x/(one-x));
  36. } else
  37. t = (float)0.5*log1pf((x+x)/(one-x));
  38. if(hx>=0) return t; else return -t;
  39. }