]>
Commit | Line | Data |
---|---|---|
94a38ea3 AJ |
1 | /* e_sinhl.c -- long double version of e_sinh.c. |
2 | * Conversion to long double by Ulrich Drepper, | |
3 | * Cygnus Support, drepper@cygnus.com. | |
4 | */ | |
5 | ||
6 | /* | |
7 | * ==================================================== | |
8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | |
9 | * | |
10 | * Developed at SunPro, a Sun Microsystems, Inc. business. | |
11 | * Permission to use, copy, modify, and distribute this | |
12 | * software is freely granted, provided that this notice | |
13 | * is preserved. | |
14 | * ==================================================== | |
15 | */ | |
16 | ||
cc7375ce RM |
17 | /* Changes for 128-bit long double are |
18 | Copyright (C) 2001 Stephen L. Moshier <moshier@na-net.ornl.gov> | |
0ac5ae23 | 19 | and are incorporated herein by permission of the author. The author |
9cd2726c | 20 | reserves the right to distribute this material elsewhere under different |
0ac5ae23 | 21 | copying permissions. These modifications are distributed here under |
9cd2726c | 22 | the following terms: |
cc7375ce RM |
23 | |
24 | This library is free software; you can redistribute it and/or | |
25 | modify it under the terms of the GNU Lesser General Public | |
26 | License as published by the Free Software Foundation; either | |
27 | version 2.1 of the License, or (at your option) any later version. | |
28 | ||
29 | This library is distributed in the hope that it will be useful, | |
30 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
31 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
32 | Lesser General Public License for more details. | |
33 | ||
34 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 PE |
35 | License along with this library; if not, see |
36 | <http://www.gnu.org/licenses/>. */ | |
94a38ea3 AJ |
37 | |
38 | /* __ieee754_sinhl(x) | |
39 | * Method : | |
40 | * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2 | |
41 | * 1. Replace x by |x| (sinhl(-x) = -sinhl(x)). | |
42 | * 2. | |
43 | * E + E/(E+1) | |
44 | * 0 <= x <= 25 : sinhl(x) := --------------, E=expm1l(x) | |
45 | * 2 | |
46 | * | |
47 | * 25 <= x <= lnovft : sinhl(x) := expl(x)/2 | |
48 | * lnovft <= x <= ln2ovft: sinhl(x) := expl(x/2)/2 * expl(x/2) | |
49 | * ln2ovft < x : sinhl(x) := x*shuge (overflow) | |
50 | * | |
51 | * Special cases: | |
52 | * sinhl(x) is |x| if x is +INF, -INF, or NaN. | |
53 | * only sinhl(0)=0 is exact for finite x. | |
54 | */ | |
55 | ||
56 | #include "math.h" | |
57 | #include "math_private.h" | |
58 | ||
94a38ea3 AJ |
59 | static const long double one = 1.0, shuge = 1.0e4931L, |
60 | ovf_thresh = 1.1357216553474703894801348310092223067821E4L; | |
94a38ea3 | 61 | |
94a38ea3 AJ |
62 | long double |
63 | __ieee754_sinhl (long double x) | |
94a38ea3 AJ |
64 | { |
65 | long double t, w, h; | |
66 | u_int32_t jx, ix; | |
67 | ieee854_long_double_shape_type u; | |
68 | ||
69 | /* Words of |x|. */ | |
70 | u.value = x; | |
71 | jx = u.parts32.w0; | |
72 | ix = jx & 0x7fffffff; | |
73 | ||
74 | /* x is INF or NaN */ | |
75 | if (ix >= 0x7fff0000) | |
76 | return x + x; | |
77 | ||
78 | h = 0.5; | |
79 | if (jx & 0x80000000) | |
80 | h = -h; | |
81 | ||
82 | /* Absolute value of x. */ | |
83 | u.parts32.w0 = ix; | |
84 | ||
85 | /* |x| in [0,40], return sign(x)*0.5*(E+E/(E+1))) */ | |
86 | if (ix <= 0x40044000) | |
87 | { | |
88 | if (ix < 0x3fc60000) /* |x| < 2^-57 */ | |
89 | if (shuge + x > one) | |
90 | return x; /* sinh(tiny) = tiny with inexact */ | |
91 | t = __expm1l (u.value); | |
92 | if (ix < 0x3fff0000) | |
93 | return h * (2.0 * t - t * t / (t + one)); | |
94 | return h * (t + t / (t + one)); | |
95 | } | |
96 | ||
97 | /* |x| in [40, log(maxdouble)] return 0.5*exp(|x|) */ | |
98 | if (ix <= 0x400c62e3) /* 11356.375 */ | |
99 | return h * __ieee754_expl (u.value); | |
100 | ||
101 | /* |x| in [log(maxdouble), overflowthreshold] | |
102 | Overflow threshold is log(2 * maxdouble). */ | |
103 | if (u.value <= ovf_thresh) | |
104 | { | |
105 | w = __ieee754_expl (0.5 * u.value); | |
106 | t = h * w; | |
107 | return t * w; | |
108 | } | |
109 | ||
110 | /* |x| > overflowthreshold, sinhl(x) overflow */ | |
111 | return x * shuge; | |
112 | } | |
0ac5ae23 | 113 | strong_alias (__ieee754_sinhl, __sinhl_finite) |