Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/LD/tanhl.c
          +++ new/usr/src/lib/libm/common/LD/tanhl.c
↓ open down ↓ 52 lines elided ↑ open up ↑
  53   53   *
  54   54   * Note: threshold was chosen so that
  55   55   *              fl(1.0+2/(expm1(2*threshold)+2)) == 1.
  56   56   *
  57   57   * Special cases:
  58   58   *      tanhl(NaN) is NaN;
  59   59   *      only tanhl(0.0)=0.0 is exact for finite argument.
  60   60   */
  61   61  
  62   62  #include "libm.h"
       63 +#include "longdouble.h"
  63   64  
  64   65  static const long double small = 1.0e-20L, one = 1.0, two = 2.0,
  65   66  #ifndef lint
  66   67          big = 1.0e+20L,
  67   68  #endif
  68   69          threshold = 45.0L;
  69   70  
  70   71  long double
  71   72  tanhl(long double x) {
  72   73          long double t, y, z;
  73   74          int signx;
       75 +        volatile long double dummy;
  74   76  
  75   77          if (isnanl(x))
  76   78                  return (x + x);         /* x is NaN */
  77   79          signx = signbitl(x);
  78   80          t = fabsl(x);
  79   81          z = one;
  80   82          if (t <= threshold) {
  81   83                  if (t > one)
  82   84                          z = one - two / (expm1l(t + t) + two);
  83   85                  else if (t > small) {
  84   86                          y = expm1l(-t - t);
  85   87                          z = -y / (y + two);
  86   88                  } else {
  87   89  #ifndef lint
  88      -                        volatile long double dummy = t + big;
       90 +                        dummy = t + big;
  89   91                                                          /* inexact if t != 0 */
  90   92  #endif
  91   93                          return (x);
  92   94                  }
  93   95          } else if (!finitel(t))
  94   96                  return (copysignl(one, x));
  95   97          else
  96   98                  return (signx ? -z + small * small : z - small * small);
  97   99          return (signx ? -z : z);
  98  100  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX