Add ChangeLog ...
[glibc.git] / sysdeps / ieee754 / dbl-64 / e_sinh.c
blobb954100baa43d523fcef2ed37fd9188d55b04683
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 #if defined(LIBM_SCCS) && !defined(lint)
14 static char rcsid[] = "$NetBSD: e_sinh.c,v 1.7 1995/05/10 20:46:13 jtc 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 static const double one = 1.0, shuge = 1.0e307;
40 double
41 __ieee754_sinh(double x)
43 double t,w,h;
44 int32_t ix,jx;
45 u_int32_t lx;
47 /* High word of |x|. */
48 GET_HIGH_WORD(jx,x);
49 ix = jx&0x7fffffff;
51 /* x is INF or NaN */
52 if(__builtin_expect(ix>=0x7ff00000, 0)) return x+x;
54 h = 0.5;
55 if (jx<0) h = -h;
56 /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
57 if (ix < 0x40360000) { /* |x|<22 */
58 if (__builtin_expect(ix<0x3e300000, 0)) /* |x|<2**-28 */
59 if(shuge+x>one)
60 return x;/* sinh(tiny) = tiny with inexact */
61 t = __expm1(fabs(x));
62 if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
63 return h*(t+t/(t+one));
66 /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
67 if (ix < 0x40862e42) return h*__ieee754_exp(fabs(x));
69 /* |x| in [log(maxdouble), overflowthresold] */
70 GET_LOW_WORD(lx,x);
71 if (ix<0x408633ce || ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
72 w = __ieee754_exp(0.5*fabs(x));
73 t = h*w;
74 return t*w;
77 /* |x| > overflowthresold, sinh(x) overflow */
78 return x*shuge;
80 strong_alias (__ieee754_sinh, __sinh_finite)