Back to index

glibc  2.9
s_asinhl.c
Go to the documentation of this file.
00001 /* s_asinhl.c -- long double version of s_asinh.c.
00002  * Conversion to long double by Ulrich Drepper,
00003  * Cygnus Support, drepper@cygnus.com.
00004  */
00005 
00006 /*
00007  * ====================================================
00008  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00009  *
00010  * Developed at SunPro, a Sun Microsystems, Inc. business.
00011  * Permission to use, copy, modify, and distribute this
00012  * software is freely granted, provided that this notice
00013  * is preserved.
00014  * ====================================================
00015  */
00016 
00017 #if defined(LIBM_SCCS) && !defined(lint)
00018 static char rcsid[] = "$NetBSD: $";
00019 #endif
00020 
00021 /* asinhl(x)
00022  * Method :
00023  *      Based on
00024  *              asinhl(x) = signl(x) * logl [ |x| + sqrtl(x*x+1) ]
00025  *      we have
00026  *      asinhl(x) := x  if  1+x*x=1,
00027  *                := signl(x)*(logl(x)+ln2)) for large |x|, else
00028  *                := signl(x)*logl(2|x|+1/(|x|+sqrtl(x*x+1))) if|x|>2, else
00029  *                := signl(x)*log1pl(|x| + x^2/(1 + sqrtl(1+x^2)))
00030  */
00031 
00032 #include "math.h"
00033 #include "math_private.h"
00034 
00035 #ifdef __STDC__
00036 static const long double
00037 #else
00038 static long double
00039 #endif
00040   one = 1.0L,
00041   ln2 = 6.931471805599453094172321214581765681e-1L,
00042   huge = 1.0e+4900L;
00043 
00044 #ifdef __STDC__
00045 long double
00046 __asinhl (long double x)
00047 #else
00048 long double
00049 __asinhl (x)
00050      long double x;
00051 #endif
00052 {
00053   long double t, w;
00054   int32_t ix, sign;
00055   ieee854_long_double_shape_type u;
00056 
00057   u.value = x;
00058   sign = u.parts32.w0;
00059   ix = sign & 0x7fffffff;
00060   if (ix == 0x7fff0000)
00061     return x + x;           /* x is inf or NaN */
00062   if (ix < 0x3fc70000)
00063     {                       /* |x| < 2^ -56 */
00064       if (huge + x > one)
00065        return x;            /* return x inexact except 0 */
00066     }
00067   u.parts32.w0 = ix;
00068   if (ix > 0x40350000)
00069     {                       /* |x| > 2 ^ 54 */
00070       w = __ieee754_logl (u.value) + ln2;
00071     }
00072   else if (ix >0x40000000)
00073     {                       /* 2^ 54 > |x| > 2.0 */
00074       t = u.value;
00075       w = __ieee754_logl (2.0 * t + one / (__ieee754_sqrtl (x * x + one) + t));
00076     }
00077   else
00078     {                       /* 2.0 > |x| > 2 ^ -56 */
00079       t = x * x;
00080       w = __log1pl (u.value + t / (one + __ieee754_sqrtl (one + t)));
00081     }
00082   if (sign & 0x80000000)
00083     return -w;
00084   else
00085     return w;
00086 }
00087 weak_alias (__asinhl, asinhl)