1 /* origin: FreeBSD /usr/src/lib/msun/src/e_coshf.c */
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
13 * ====================================================
18 static const float huge = 1.0e30;
25 GET_FLOAT_WORD(ix, x);
32 /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
33 if (ix < 0x3eb17218) {
37 return 1.0f; /* cosh(tiny) = 1 */
38 return 1.0f + (t*t)/(w+w);
41 /* |x| in [0.5*ln2,9], return (exp(|x|)+1/exp(|x|))/2; */
42 if (ix < 0x41100000) {
44 return 0.5f*t + 0.5f/t;
47 /* |x| in [9, log(maxfloat)] return 0.5f*exp(|x|) */
49 return 0.5f*expf(fabsf(x));
51 /* |x| in [log(maxfloat), overflowthresold] */
53 return __expo2f(fabsf(x));
55 /* |x| > overflowthresold, cosh(x) overflow */