123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #if defined(LIBM_SCCS) && !defined(lint)
- static char rcsid[] = "$NetBSD: e_cosh.c,v 1.7 1995/05/10 20:44:58 jtc Exp $";
- #endif
- #include "math.h"
- #include "math_private.h"
- libm_hidden_proto(expm1)
- libm_hidden_proto(fabs)
- #ifdef __STDC__
- static const double one = 1.0, half=0.5, huge = 1.0e300;
- #else
- static double one = 1.0, half=0.5, huge = 1.0e300;
- #endif
- #ifdef __STDC__
- double attribute_hidden __ieee754_cosh(double x)
- #else
- double attribute_hidden __ieee754_cosh(x)
- double x;
- #endif
- {
- double t,w;
- int32_t ix;
- u_int32_t lx;
-
- GET_HIGH_WORD(ix,x);
- ix &= 0x7fffffff;
-
- if(ix>=0x7ff00000) return x*x;
-
- if(ix<0x3fd62e43) {
- t = expm1(fabs(x));
- w = one+t;
- if (ix<0x3c800000) return w;
- return one+(t*t)/(w+w);
- }
-
- if (ix < 0x40360000) {
- t = __ieee754_exp(fabs(x));
- return half*t+half/t;
- }
-
- if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x));
-
- GET_LOW_WORD(lx,x);
- if (ix<0x408633CE ||
- ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
- w = __ieee754_exp(half*fabs(x));
- t = half*w;
- return t*w;
- }
-
- return huge*huge;
- }
|