Renamed INT[B|F]_VERTB100 to INT[B|F]_TIMERTICK
[tangerine.git] / compiler / mlib / e_sinh.c
blob361916217432364c7c75ca90433f9cd3adbc6f45
1 /* @(#)e_sinh.c 5.1 93/09/24 */
2 /*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
13 #ifndef lint
14 static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_sinh.c,v 1.6 1999/08/28 00:06:39 peter Exp $";
15 #endif
17 /* __ieee754_sinh(x)
18 * Method :
19 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
20 * 1. Replace x by |x| (sinh(-x) = -sinh(x)).
21 * 2.
22 * E + E/(E+1)
23 * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)
24 * 2
26 * 22 <= x <= lnovft : sinh(x) := exp(x)/2
27 * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)
28 * ln2ovft < x : sinh(x) := x*shuge (overflow)
30 * Special cases:
31 * sinh(x) is |x| if x is +INF, -INF, or NaN.
32 * only sinh(0)=0 is exact for finite x.
35 #include "math.h"
36 #include "math_private.h"
38 #ifdef __STDC__
39 static const double one = 1.0, shuge = 1.0e307;
40 #else
41 static double one = 1.0, shuge = 1.0e307;
42 #endif
44 #ifdef __STDC__
45 double __ieee754_sinh(double x)
46 #else
47 double __ieee754_sinh(x)
48 double x;
49 #endif
51 double t,w,h;
52 int32_t ix,jx;
53 uint32_t lx;
55 /* High word of |x|. */
56 GET_HIGH_WORD(jx,x);
57 ix = jx&0x7fffffff;
59 /* x is INF or NaN */
60 if(ix>=0x7ff00000) return x+x;
62 h = 0.5;
63 if (jx<0) h = -h;
64 /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
65 if (ix < 0x40360000) { /* |x|<22 */
66 if (ix<0x3e300000) /* |x|<2**-28 */
67 if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
68 t = expm1(fabs(x));
69 if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
70 return h*(t+t/(t+one));
73 /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
74 if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x));
76 /* |x| in [log(maxdouble), overflowthresold] */
77 GET_LOW_WORD(lx,x);
78 if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(uint32_t)0x8fb9f87d))) {
79 w = __ieee754_exp(0.5*fabs(x));
80 t = h*w;
81 return t*w;
84 /* |x| > overflowthresold, sinh(x) overflow */
85 return x*shuge;