1 /* ef_sinh.c -- float version of e_sinh.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3 */
4
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 *
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
12 * is preserved.
13 * ====================================================
14 */
15
16 #include "fdlibm.h"
17
18 static const float one = 1.0, shuge = 1.0e37;
19
20 float
sinhf(float x)21 sinhf(float x)
22 {
23 float t, w, h;
24 __int32_t ix, jx;
25
26 GET_FLOAT_WORD(jx, x);
27 ix = jx & 0x7fffffff;
28
29 /* x is INF or NaN */
30 if (!FLT_UWORD_IS_FINITE(ix))
31 return x + x;
32
33 h = 0.5;
34 if (jx < 0)
35 h = -h;
36 /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
37 if (ix < 0x41b00000) { /* |x|<22 */
38 if (ix < 0x31800000) /* |x|<2**-28 */
39 if (shuge + x > one)
40 return x; /* sinh(tiny) = tiny with inexact */
41 t = expm1f(fabsf(x));
42 if (ix < 0x3f800000)
43 return h * ((float)2.0 * t - t * t / (t + one));
44 return h * (t + t / (t + one));
45 }
46
47 /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
48 if (ix <= FLT_UWORD_LOG_MAX)
49 return h * expf(fabsf(x));
50
51 /* |x| in [log(maxdouble), overflowthresold] */
52 if (ix <= FLT_UWORD_LOG_2MAX) {
53 w = expf((float)0.5 * fabsf(x));
54 t = h * w;
55 return t * w;
56 }
57
58 /* |x| > overflowthresold, sinh(x) overflow */
59 return __math_oflowf(x < 0);
60 }
61
62 _MATH_ALIAS_f_f(sinh)
63