fdisk - Use heads = 255 on file images
[dragonfly.git] / lib / libm / src / e_sinh.c
blob4d54278b5c32b97b467d809aa67daec088ee9618
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 * ====================================================
12 * $NetBSD: e_sinh.c,v 1.11 2002/05/26 22:01:52 wiz Exp $
13 * $DragonFly: src/lib/libm/src/e_sinh.c,v 1.1 2005/07/26 21:15:20 joerg Exp $
16 /* sinh(x)
17 * Method :
18 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
19 * 1. Replace x by |x| (sinh(-x) = -sinh(x)).
20 * 2.
21 * E + E/(E+1)
22 * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)
23 * 2
25 * 22 <= x <= lnovft : sinh(x) := exp(x)/2
26 * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)
27 * ln2ovft < x : sinh(x) := x*shuge (overflow)
29 * Special cases:
30 * sinh(x) is |x| if x is +INF, -INF, or NaN.
31 * only sinh(0)=0 is exact for finite x.
34 #include <math.h>
35 #include "math_private.h"
37 static const double one = 1.0, shuge = 1.0e307;
39 double
40 sinh(double x)
42 double t,w,h;
43 int32_t ix,jx;
44 u_int32_t lx;
46 /* High word of |x|. */
47 GET_HIGH_WORD(jx,x);
48 ix = jx&0x7fffffff;
50 /* x is INF or NaN */
51 if(ix>=0x7ff00000) return x+x;
53 h = 0.5;
54 if (jx<0) h = -h;
55 /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
56 if (ix < 0x40360000) { /* |x|<22 */
57 if (ix<0x3e300000) /* |x|<2**-28 */
58 if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
59 t = expm1(fabs(x));
60 if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
61 return h*(t+t/(t+one));
64 /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
65 if (ix < 0x40862E42) return h*exp(fabs(x));
67 /* |x| in [log(maxdouble), overflowthresold] */
68 GET_LOW_WORD(lx,x);
69 if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
70 w = exp(0.5*fabs(x));
71 t = h*w;
72 return t*w;
75 /* |x| > overflowthresold, sinh(x) overflow */
76 return x*shuge;