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 * ====================================================
20 union {float f; uint32_t i;} u = {.f = x};
29 /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
30 if (ix < 0x3eb17218) {
34 return 1 + t*t/(2*(1+t));
37 /* |x| in [0.5*ln2,9], return (exp(|x|)+1/exp(|x|))/2; */
38 if (ix < 0x41100000) {
40 return 0.5f*t + 0.5f/t;
43 /* |x| in [9, log(maxfloat)] return 0.5f*exp(|x|) */
47 /* |x| in [log(maxfloat), overflowthresold] */
51 /* |x| > overflowthresold or nan */