Back to index

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

Go to the source code of this file.

Functions

long double __tanhl (long double x)
 long_double_symbol (libm, __tanhl, tanhl)

Variables

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

Function Documentation

long double __tanhl ( long double  x)

Definition at line 54 of file s_tanhl.c.

{
       long double t,z;
       int64_t jx,ix,lx;

    /* High word of |x|. */
       GET_LDOUBLE_WORDS64(jx,lx,x);
       ix = jx&0x7fffffffffffffffLL;

    /* x is INF or NaN */
       if(ix>=0x7ff0000000000000LL) {
           if (jx>=0) return one/x+one;    /* tanh(+-inf)=+-1 */
           else       return one/x-one;    /* tanh(NaN) = NaN */
       }

    /* |x| < 22 */
       if (ix < 0x4036000000000000LL) {          /* |x|<22 */
           if ((ix | (lx&0x7fffffffffffffffLL)) == 0)
              return x;            /* x == +-0 */
           if (ix<0x3c60000000000000LL)   /* |x|<2**-57 */
              return x*(one+x);           /* tanh(small) = small */
           if (ix>=0x3ff0000000000000LL) {       /* |x|>=1  */
              t = __expm1l(two*fabsl(x));
              z = one - two/(t+two);
           } else {
               t = __expm1l(-two*fabsl(x));
               z= -t/(t+two);
           }
    /* |x| > 22, return +-1 */
       } else {
           z = one - tiny;         /* raised inexact flag */
       }
       return (jx>=0)? z: -z;
}

Here is the call graph for this function:

long_double_symbol ( libm  ,
__tanhl  ,
tanhl   
)

Variable Documentation

long double one = 1.0L [static]

Definition at line 48 of file s_tanhl.c.

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

Definition at line 48 of file s_tanhl.c.

long double two = 2.0L [static]

Definition at line 48 of file s_tanhl.c.