123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #include <openlibm.h>
- #include "math_private.h"
- static const long double one = 1.0, half = 0.5, huge = 1.0e4900L,
- ovf_thresh = 1.1357216553474703894801348310092223067821E4L;
- long double
- coshl(long double x)
- {
- long double t, w;
- int32_t ex;
- ieee_quad_shape_type u;
- u.value = x;
- ex = u.parts32.mswhi & 0x7fffffff;
-
- u.parts32.mswhi = ex;
-
- if (ex >= 0x7fff0000)
- return x * x;
-
- if (ex < 0x3ffd62e4)
- {
- t = expm1l (u.value);
- w = one + t;
- if (ex < 0x3fb80000)
- return w;
- return one + (t * t) / (w + w);
- }
-
- if (ex < 0x40044000)
- {
- t = expl (u.value);
- return half * t + half / t;
- }
-
- if (ex <= 0x400c62e3)
- return half * expl (u.value);
-
- if (u.value <= ovf_thresh)
- {
- w = expl (half * u.value);
- t = half * w;
- return t * w;
- }
-
- return huge * huge;
- }
|