s_asinhf.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* s_asinhf.c -- float version of s_asinh.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_asinhf.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. one = 1.0000000000e+00, /* 0x3F800000 */
  20. ln2 = 6.9314718246e-01, /* 0x3f317218 */
  21. huge= 1.0000000000e+30;
  22. DLLEXPORT float
  23. asinhf(float x)
  24. {
  25. float t,w;
  26. int32_t hx,ix;
  27. GET_FLOAT_WORD(hx,x);
  28. ix = hx&0x7fffffff;
  29. if(ix>=0x7f800000) return x+x; /* x is inf or NaN */
  30. if(ix< 0x31800000) { /* |x|<2**-28 */
  31. if(huge+x>one) return x; /* return x inexact except 0 */
  32. }
  33. if(ix>0x4d800000) { /* |x| > 2**28 */
  34. w = __ieee754_logf(fabsf(x))+ln2;
  35. } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */
  36. t = fabsf(x);
  37. w = __ieee754_logf((float)2.0*t+one/(__ieee754_sqrtf(x*x+one)+t));
  38. } else { /* 2.0 > |x| > 2**-28 */
  39. t = x*x;
  40. w =log1pf(fabsf(x)+t/(one+__ieee754_sqrtf(one+t)));
  41. }
  42. if(hx>0) return w; else return -w;
  43. }