Back to index

glibc  2.9
Functions | Variables
s_tanhl.c File Reference
#include "math.h"
#include "math_private.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

long double __tanhl (long double x)

Variables

static long double one = 1.0
static long double two = 2.0
static long double tiny = 1.0e-4900L

Function Documentation

long double __tanhl ( long double  x)

Definition at line 58 of file s_tanhl.c.

{
  long double t, z;
  u_int32_t jx, ix;
  ieee854_long_double_shape_type u;

  /* Words of |x|. */
  u.value = x;
  jx = u.parts32.w0;
  ix = jx & 0x7fffffff;
  /* x is INF or NaN */
  if (ix >= 0x7fff0000)
    {
      /* for NaN it's not important which branch: tanhl(NaN) = NaN */
      if (jx & 0x80000000)
       return one / x - one;       /* tanhl(-inf)= -1; */
      else
       return one / x + one;       /* tanhl(+inf)=+1 */
    }

  /* |x| < 40 */
  if (ix < 0x40044000)
    {
      if (u.value == 0)
       return x;            /* x == +- 0 */
      if (ix < 0x3fc60000)  /* |x| < 2^-57 */
       return x * (one + tiny); /* tanh(small) = small */
      u.parts32.w0 = ix;    /* Absolute value of x.  */
      if (ix >= 0x3fff0000)
       {                    /* |x| >= 1  */
         t = __expm1l (two * u.value);
         z = one - two / (t + two);
       }
      else
       {
         t = __expm1l (-two * u.value);
         z = -t / (t + two);
       }
      /* |x| > 40, return +-1 */
    }
  else
    {
      z = one - tiny;              /* raised inexact flag */
    }
  return (jx & 0x80000000) ? -z : z;
}

Here is the call graph for this function:


Variable Documentation

long double one = 1.0 [static]

Definition at line 50 of file s_tanhl.c.

long double tiny = 1.0e-4900L [static]

Definition at line 50 of file s_tanhl.c.

long double two = 2.0 [static]

Definition at line 50 of file s_tanhl.c.