Print this page
11210 libm should be cstyle(1ONBLD) clean

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/Q/exp10l.c
          +++ new/usr/src/lib/libm/common/Q/exp10l.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
       25 +
  25   26  /*
  26   27   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  27   28   * Use is subject to license terms.
  28   29   */
  29   30  
  30   31  #include "libm.h"
  31   32  #include "longdouble.h"
  32   33  
  33   34  /*
  34   35   * exp10l(x)
  35   36   *      n = nint(x*(log10/log2)) ;
  36   37   *      exp10(x) = 10**x = exp(x*ln(10)) = exp(n*ln2+(x*ln10-n*ln2))
  37   38   *               = 2**n*exp(ln10*(x-n*log2/log10)))
  38   39   *      If x is an integer <= M then use repeat multiplication. For
  39   40   *      10**M is the largest representable integer, where
  40   41   *              M = 10          single precision (24 bits)
  41   42   *              M = 22          double precision (53 bits)
  42   43   *              M = 48          quadruple precision (113 bits)
  43   44   */
  44   45  
  45      -#define TINY    1.0e-20L        /* single: 1e-5, double: 1e-10, quad: 1e-20 */
       46 +#define TINY    1.0e-20L        /* single: 1e-5, double: 1e-10, quad: 1e-20 */
  46   47  #define LG10OVT 4933.L          /* single:  39, double:  309, quad:  4933 */
  47   48  #define LG10UFT -4966.L         /* single: -45, double: -323, quad: -4966 */
  48      -#define M       48
  49      -                        /* logt2hi : last 32 bits is zero for quad prec */
  50      -#define LOGT2HI 0.30102999566398119521373889472420986034688L
  51      -#define LOGT2LO 2.831664213089468167896664371953e-31L
  52      -
  53      -static const long double
  54      -        zero    = 0.0L,
  55      -        tiny    = TINY * TINY,
  56      -        one     = 1.0L,
  57      -        lg10    = 3.321928094887362347870319429489390175865e+0000L,
  58      -        ln10    = 2.302585092994045684017991454684364207601e+0000L,
  59      -        logt2hi = LOGT2HI,
  60      -        logt2lo = LOGT2LO,
  61      -        lg10ovt = LG10OVT,
  62      -        lg10uft = LG10UFT;
       49 +#define M               48
       50 +/* logt2hi : last 32 bits is zero for quad prec */
       51 +#define LOGT2HI         0.30102999566398119521373889472420986034688L
       52 +#define LOGT2LO         2.831664213089468167896664371953e-31L
       53 +
       54 +static const long double zero = 0.0L,
       55 +        tiny = TINY * TINY,
       56 +        one = 1.0L,
       57 +        lg10 = 3.321928094887362347870319429489390175865e+0000L,
       58 +        ln10 = 2.302585092994045684017991454684364207601e+0000L,
       59 +        logt2hi = LOGT2HI,
       60 +        logt2lo = LOGT2LO,
       61 +        lg10ovt = LG10OVT,
       62 +        lg10uft = LG10UFT;
  63   63  
  64   64  long double
  65      -exp10l(long double x) {
       65 +exp10l(long double x)
       66 +{
  66   67          long double t, tenp;
  67   68          int k;
  68   69  
  69   70          if (!finitel(x)) {
  70   71                  if (isnanl(x) || x > zero)
  71   72                          return (x + x);
  72   73                  else
  73   74                          return (zero);
  74   75          }
       76 +
  75   77          if (fabsl(x) < tiny)
  76   78                  return (one + x);
  77      -        if (x <= lg10ovt)
       79 +
       80 +        if (x <= lg10ovt) {
  78   81                  if (x >= lg10uft) {
  79      -                        k = (int) x;
       82 +                        k = (int)x;
  80   83                          tenp = 10.0L;
  81      -                                        /* x is a small +integer */
  82      -                        if (0 <= k && k <= M && (long double) k == x) {
       84 +
       85 +                        /* x is a small +integer */
       86 +                        if (0 <= k && k <= M && (long double)k == x) {
  83   87                                  t = one;
       88 +
  84   89                                  if (k & 1)
  85   90                                          t *= tenp;
       91 +
  86   92                                  k >>= 1;
       93 +
  87   94                                  while (k) {
  88   95                                          tenp *= tenp;
       96 +
  89   97                                          if (k & 1)
  90   98                                                  t *= tenp;
       99 +
  91  100                                          k >>= 1;
  92  101                                  }
      102 +
  93  103                                  return (t);
  94  104                          }
      105 +
  95  106                          t = anintl(x * lg10);
  96      -                        return (scalbnl(expl(ln10 * ((x - t * logt2hi) -
  97      -                                t * logt2lo)), (int) t));
  98      -                } else
      107 +                        return (scalbnl(expl(ln10 * ((x - t * logt2hi) - t *
      108 +                            logt2lo)), (int)t));
      109 +                } else {
  99  110                          return (scalbnl(one, -50000));  /* underflow */
 100      -        else
 101      -                        return (scalbnl(one, 50000));   /* overflow  */
      111 +                }
      112 +        } else {
      113 +                return (scalbnl(one, 50000));           /* overflow  */
      114 +        }
 102  115  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX