Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/C/log1p.c
          +++ new/usr/src/lib/libm/common/C/log1p.c
↓ open down ↓ 115 lines elided ↑ open up ↑
 116  116  #define Lp2     xxx[4]
 117  117  #define Lp3     xxx[5]
 118  118  #define Lp4     xxx[6]
 119  119  #define Lp5     xxx[7]
 120  120  #define Lp6     xxx[8]
 121  121  #define Lp7     xxx[9]
 122  122  #define zero    xxx[10]
 123  123  
 124  124  double
 125  125  log1p(double x) {
 126      -        double  hfsq, f, c, s, z, R, u;
      126 +        double  hfsq, f, c = 0.0, s, z, R, u;
 127  127          int     k, hx, hu, ax;
 128  128  
 129  129          hx = ((int *)&x)[HIWORD];               /* high word of x */
 130  130          ax = hx & 0x7fffffff;
 131  131  
 132  132          if (ax >= 0x7ff00000) { /* x is inf or nan */
 133  133                  if (((hx - 0xfff00000) | ((int *)&x)[LOWORD]) == 0) /* -inf */
 134  134                          return (_SVID_libm_err(x, x, 44));
 135  135                  return (x * x);
 136  136          }
↓ open down ↓ 8 lines elided ↑ open up ↑
 145  145                                  return (x);
 146  146                          else
 147  147                                  return (x - x * x * 0.5);
 148  148                  }
 149  149                  if (hx > 0 || hx <= (int)0xbfd2bec3) {  /* -0.2929<x<0.41422 */
 150  150                          k = 0;
 151  151                          f = x;
 152  152                          hu = 1;
 153  153                  }
 154  154          }
      155 +        /* We will initialize 'c' here. */
 155  156          if (k != 0) {
 156  157                  if (hx < 0x43400000) {
 157  158                          u = 1.0 + x;
 158  159                          hu = ((int *)&u)[HIWORD];       /* high word of u */
 159  160                          k = (hu >> 20) - 1023;
 160  161                          /*
 161  162                           * correction term
 162  163                           */
 163  164                          c = k > 0 ? 1.0 - (u - x) : x - (u - 1.0);
 164  165                          c /= u;
↓ open down ↓ 11 lines elided ↑ open up ↑
 176  177                          ((int *)&u)[HIWORD] = hu | 0x3fe00000;
 177  178                          hu = (0x00100000 - hu) >> 2;
 178  179                  }
 179  180                  f = u - 1.0;
 180  181          }
 181  182          hfsq = 0.5 * f * f;
 182  183          if (hu == 0) {          /* |f| < 2**-20 */
 183  184                  if (f == zero) {
 184  185                          if (k == 0)
 185  186                                  return (zero);
      187 +                        /* We already initialized 'c' before, when (k != 0) */
 186  188                          c += k * ln2_lo;
 187  189                          return (k * ln2_hi + c);
 188  190                  }
 189  191                  R = hfsq * (1.0 - 0.66666666666666666 * f);
 190  192                  if (k == 0)
 191  193                          return (f - R);
 192  194                  return (k * ln2_hi - ((R - (k * ln2_lo + c)) - f));
 193  195          }
 194  196          s = f / (2.0 + f);
 195  197          z = s * s;
 196  198          R = z * (Lp1 + z * (Lp2 + z * (Lp3 + z * (Lp4 + z * (Lp5 +
 197  199                  z * (Lp6 + z * Lp7))))));
 198  200          if (k == 0)
 199  201                  return (f - (hfsq - s * (hfsq + R)));
 200  202          return (k * ln2_hi - ((hfsq - (s * (hfsq + R) +
 201  203                  (k * ln2_lo + c))) - f));
 202  204  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX