Cygwin: utils: cygpath: add -r option to emit paths with root-local prefix
[newlib-cygwin.git] / winsup / cygwin / math / coshl.c
blobe63699625f46cafb255258f5b82622d598f462f1
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6 #include "cephes_mconf.h"
8 #ifndef _SET_ERRNO
9 #define _SET_ERRNO(x)
10 #endif
12 long double coshl(long double x)
14 long double y;
15 int x_class = fpclassify (x);
16 if (x_class == FP_NAN)
18 errno = EDOM;
19 return x;
21 else if (x_class == FP_INFINITE)
23 errno = ERANGE;
24 return INFINITY;
26 x = fabsl (x);
27 if (x > (MAXLOGL + LOGE2L))
29 errno = ERANGE;
30 #ifdef INFINITIES
31 return (INFINITYL);
32 #else
33 return (MAXNUML);
34 #endif
36 if (x >= (MAXLOGL - LOGE2L))
38 y = expl(0.5L * x);
39 y = (0.5L * y) * y;
40 return y;
42 y = expl(x);
43 y = 0.5L * (y + 1.0L / y);
44 return y;