1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #include <openlibm_math.h>
- #include "math_private.h"
- static const long double one = 1.0, half=0.5, huge = 1.0e4900L;
- long double
- coshl(long double x)
- {
- long double t,w;
- int32_t ex;
- u_int32_t mx,lx;
-
- GET_LDOUBLE_WORDS(ex,mx,lx,x);
- ex &= 0x7fff;
-
- if(ex==0x7fff) return x*x;
-
- if(ex < 0x3ffd || (ex == 0x3ffd && mx < 0xb17217f7u)) {
- t = expm1l(fabsl(x));
- w = one+t;
- if (ex<0x3fbc) return w;
- return one+(t*t)/(w+w);
- }
-
- if (ex < 0x4003 || (ex == 0x4003 && mx < 0xb0000000u)) {
- t = expl(fabsl(x));
- return half*t+half/t;
- }
-
- if (ex < 0x400c || (ex == 0x400c && mx < 0xb1700000u))
- return half*expl(fabsl(x));
-
- if (ex == 0x400c && (mx < 0xb174ddc0u
- || (mx == 0xb174ddc0u && lx < 0x31aec0ebu)))
- {
- w = expl(half*fabsl(x));
- t = half*w;
- return t*w;
- }
-
- return huge*huge;
- }
|