]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /* @(#)e_sinh.c 5.1 93/09/24 */\r |
2 | /*\r | |
3 | * ====================================================\r | |
4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\r | |
5 | *\r | |
6 | * Developed at SunPro, a Sun Microsystems, Inc. business.\r | |
7 | * Permission to use, copy, modify, and distribute this\r | |
8 | * software is freely granted, provided that this notice\r | |
9 | * is preserved.\r | |
10 | * ====================================================\r | |
11 | */\r | |
12 | #include <LibConfig.h>\r | |
13 | #include <sys/EfiCdefs.h>\r | |
14 | #if defined(LIBM_SCCS) && !defined(lint)\r | |
15 | __RCSID("$NetBSD: e_sinh.c,v 1.11 2002/05/26 22:01:52 wiz Exp $");\r | |
16 | #endif\r | |
17 | \r | |
18 | #include "math.h"\r | |
19 | #include "math_private.h"\r | |
20 | \r | |
21 | /* __ieee754_sinh(x)\r | |
22 | * Method :\r | |
23 | * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2\r | |
24 | * 1. Replace x by |x| (sinh(-x) = -sinh(x)).\r | |
25 | * 2.\r | |
26 | * E + E/(E+1)\r | |
27 | * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x)\r | |
28 | * 2\r | |
29 | *\r | |
30 | * 22 <= x <= lnovft : sinh(x) := exp(x)/2\r | |
31 | * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2)\r | |
32 | * ln2ovft < x : sinh(x) := x*shuge (overflow)\r | |
33 | *\r | |
34 | * Special cases:\r | |
35 | * sinh(x) is |x| if x is +INF, -INF, or NaN.\r | |
36 | * only sinh(0)=0 is exact for finite x.\r | |
37 | */\r | |
38 | \r | |
39 | static const double one = 1.0, shuge = 1.0e307;\r | |
40 | \r | |
41 | double\r | |
42 | __ieee754_sinh(double x)\r | |
43 | {\r | |
44 | double t,w,h;\r | |
45 | int32_t ix,jx;\r | |
46 | u_int32_t lx;\r | |
47 | \r | |
48 | /* High word of |x|. */\r | |
49 | GET_HIGH_WORD(jx,x);\r | |
50 | ix = jx&0x7fffffff;\r | |
51 | \r | |
52 | /* x is INF or NaN */\r | |
53 | if(ix>=0x7ff00000) return x+x;\r | |
54 | \r | |
55 | h = 0.5;\r | |
56 | if (jx<0) h = -h;\r | |
57 | /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */\r | |
58 | if (ix < 0x40360000) { /* |x|<22 */\r | |
59 | if (ix<0x3e300000) /* |x|<2**-28 */\r | |
60 | if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */\r | |
61 | t = expm1(fabs(x));\r | |
62 | if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));\r | |
63 | return h*(t+t/(t+one));\r | |
64 | }\r | |
65 | \r | |
66 | /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */\r | |
67 | if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x));\r | |
68 | \r | |
69 | /* |x| in [log(maxdouble), overflowthresold] */\r | |
70 | GET_LOW_WORD(lx,x);\r | |
71 | if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {\r | |
72 | w = __ieee754_exp(0.5*fabs(x));\r | |
73 | t = h*w;\r | |
74 | return t*w;\r | |
75 | }\r | |
76 | \r | |
77 | /* |x| > overflowthresold, sinh(x) overflow */\r | |
78 | return x*shuge;\r | |
79 | }\r |