Back to index

glibc  2.9
Functions | Variables
s_tanhl.c File Reference
#include "math.h"
#include "math_private.h"

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 57 of file s_tanhl.c.

{
       long double t,z;
       int32_t se;
       u_int32_t j0,j1,ix;

    /* High word of |x|. */
       GET_LDOUBLE_WORDS(se,j0,j1,x);
       ix = se&0x7fff;

    /* x is INF or NaN */
       if(ix==0x7fff) {
           /* for NaN it's not important which branch: tanhl(NaN) = NaN */
           if (se&0x8000) return one/x-one;      /* tanhl(-inf)= -1; */
           else           return one/x+one;      /* tanhl(+inf)=+1 */
       }

    /* |x| < 23 */
       if (ix < 0x4003 || (ix == 0x4003 && j0 < 0xb8000000u)) {/* |x|<23 */
           if ((ix|j0|j1) == 0)
              return x;            /* x == +- 0 */
           if (ix<0x3fc8)          /* |x|<2**-55 */
              return x*(one+tiny); /* tanh(small) = small */
           if (ix>=0x3fff) {       /* |x|>=1  */
              t = __expm1l(two*fabsl(x));
              z = one - two/(t+two);
           } else {
               t = __expm1l(-two*fabsl(x));
               z= -t/(t+two);
           }
    /* |x| > 23, return +-1 */
       } else {
           z = one - tiny;         /* raised inexact flag */
       }
       return (se&0x8000)? -z: z;
}

Here is the call graph for this function:


Variable Documentation

long double one = 1.0 [static]

Definition at line 51 of file s_tanhl.c.

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

Definition at line 51 of file s_tanhl.c.

long double two = 2.0 [static]

Definition at line 51 of file s_tanhl.c.