1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #if defined(LIBM_SCCS) && !defined(lint)
- static char rcsid[] = "$NetBSD: e_atanh.c,v 1.8 1995/05/10 20:44:55 jtc Exp $";
- #endif
- #include "math.h"
- #include "math_private.h"
- #ifdef __STDC__
- static const double one = 1.0, huge = 1e300;
- #else
- static double one = 1.0, huge = 1e300;
- #endif
- #ifdef __STDC__
- static const double zero = 0.0;
- #else
- static double zero = 0.0;
- #endif
- #ifdef __STDC__
- double __ieee754_atanh(double x)
- #else
- double __ieee754_atanh(x)
- double x;
- #endif
- {
- double t;
- int32_t hx,ix;
- u_int32_t lx;
- EXTRACT_WORDS(hx,lx,x);
- ix = hx&0x7fffffff;
- if ((ix|((lx|(-lx))>>31))>0x3ff00000)
- return (x-x)/(x-x);
- if(ix==0x3ff00000)
- return x/zero;
- if(ix<0x3e300000&&(huge+x)>zero) return x;
- SET_HIGH_WORD(x,ix);
- if(ix<0x3fe00000) {
- t = x+x;
- t = 0.5*log1p(t+t*x/(one-x));
- } else
- t = 0.5*log1p((x+x)/(one-x));
- if(hx>=0) return t; else return -t;
- }
|