forwarding a patch that uses the fetch macros to pull in acpica and build it (NicJA).
[AROS.git] / compiler / stdc / math / e_sinh.c
blobb17eeb63aa1030a109d2373a45ada77d8e1a1ac3
2 /* @(#)e_sinh.c 1.3 95/01/18 */
3 /*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunSoft, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
10 * is preserved.
11 * ====================================================
14 #ifndef lint
15 static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_sinh.c,v 1.11 2011/10/21 06:28:47 das Exp $";
16 #endif
18 /* __ieee754_sinh(x)
19 * Method :
20 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
21 * 1. Replace x by |x| (sinh(-x) = -sinh(x)).
22 * 2.
23 * E + E/(E+1)
24 * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)
25 * 2
27 * 22 <= x <= lnovft : sinh(x) := exp(x)/2
28 * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)
29 * ln2ovft < x : sinh(x) := x*shuge (overflow)
31 * Special cases:
32 * sinh(x) is |x| if x is +INF, -INF, or NaN.
33 * only sinh(0)=0 is exact for finite x.
36 #include <float.h>
37 #include "math.h"
38 #include "math_private.h"
40 static const double one = 1.0, shuge = 1.0e307;
42 double
43 __ieee754_sinh(double x)
45 double t,h;
46 int32_t ix,jx;
48 /* High word of |x|. */
49 GET_HIGH_WORD(jx,x);
50 ix = jx&0x7fffffff;
52 /* x is INF or NaN */
53 if(ix>=0x7ff00000) return x+x;
55 h = 0.5;
56 if (jx<0) h = -h;
57 /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
58 if (ix < 0x40360000) { /* |x|<22 */
59 if (ix<0x3e300000) /* |x|<2**-28 */
60 if(shuge+x>one) 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 if (ix<=0x408633CE)
71 return h*2.0*__ldexp_exp(fabs(x), -1);
73 /* |x| > overflowthresold, sinh(x) overflow */
74 return x*shuge;
77 #if (LDBL_MANT_DIG == 53)
78 AROS_MAKE_ASM_SYM(typeof(sinhl), sinhl, AROS_CSYM_FROM_ASM_NAME(sinhl), AROS_CSYM_FROM_ASM_NAME(sinh));
79 AROS_EXPORT_ASM_SYM(AROS_CSYM_FROM_ASM_NAME(sinhl));
80 #endif