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