1/* asinhq.c -- __float128 version of s_asinh.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
17/* asinhl(x)
18 * Method :
19 * Based on
20 * asinhl(x) = signl(x) * logl [ |x| + sqrtl(x*x+1) ]
21 * we have
22 * asinhl(x) := x if 1+x*x=1,
23 * := signl(x)*(logl(x)+ln2)) for large |x|, else
24 * := signl(x)*logl(2|x|+1/(|x|+sqrtl(x*x+1))) if|x|>2, else
25 * := signl(x)*log1pl(|x| + x^2/(1 + sqrtl(1+x^2)))
26 */
27
28#include "quadmath-imp.h"
29
30static const __float128
31 one = 1.0Q,
32 ln2 = 6.931471805599453094172321214581765681e-1Q,
33 huge = 1.0e+4900Q;
34
35__float128
36asinhq (__float128 x)
37{
38 __float128 t, w;
39 int32_t ix, sign;
40 ieee854_float128 u;
41
42 u.value = x;
43 sign = u.words32.w0;
44 ix = sign & 0x7fffffff;
45 if (ix == 0x7fff0000)
46 return x + x; /* x is inf or NaN */
47 if (ix < 0x3fc70000)
48 { /* |x| < 2^ -56 */
49 math_check_force_underflow (x);
50 if (huge + x > one)
51 return x; /* return x inexact except 0 */
52 }
53 u.words32.w0 = ix;
54 if (ix > 0x40350000)
55 { /* |x| > 2 ^ 54 */
56 w = logq (u.value) + ln2;
57 }
58 else if (ix >0x40000000)
59 { /* 2^ 54 > |x| > 2.0 */
60 t = u.value;
61 w = logq (2.0 * t + one / (sqrtq (x * x + one) + t));
62 }
63 else
64 { /* 2.0 > |x| > 2 ^ -56 */
65 t = x * x;
66 w = log1pq (u.value + t / (one + sqrtq (one + t)));
67 }
68 if (sign & 0x80000000)
69 return -w;
70 else
71 return w;
72}
73