~ubuntu-branches/ubuntu/wily/musl/wily

« back to all changes in this revision

Viewing changes to src/math/exp.c

  • Committer: Package Import Robot
  • Author(s): Kevin Bortis
  • Date: 2013-09-27 23:47:18 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130927234718-a96bgcnvzx5buf60
Tags: 0.9.14-1
* Import upstream version 0.9.14
* Only build on fully supported architectures
* Point to new homepage in control file (Closes: #724277)
* Revorked debian/rules
* Solved possible problem with postrm script (Closes: #724247)

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
 
81
81
double exp(double x)
82
82
{
83
 
        double hi, lo, c, xx;
 
83
        double_t hi, lo, c, xx, y;
84
84
        int k, sign;
85
85
        uint32_t hx;
86
86
 
89
89
        hx &= 0x7fffffff;  /* high word of |x| */
90
90
 
91
91
        /* special cases */
92
 
        if (hx >= 0x40862e42) {  /* if |x| >= 709.78... */
 
92
        if (hx >= 0x4086232b) {  /* if |x| >= 708.39... */
93
93
                if (isnan(x))
94
94
                        return x;
95
 
                if (hx == 0x7ff00000 && sign) /* -inf */
96
 
                        return 0;
97
95
                if (x > 709.782712893383973096) {
98
96
                        /* overflow if x!=inf */
99
 
                        STRICT_ASSIGN(double, x, 0x1p1023 * x);
 
97
                        x *= 0x1p1023;
100
98
                        return x;
101
99
                }
102
 
                if (x < -745.13321910194110842) {
103
 
                        /* underflow */
104
 
                        STRICT_ASSIGN(double, x, 0x1p-1000 * 0x1p-1000);
105
 
                        return x;
 
100
                if (x < -708.39641853226410622) {
 
101
                        /* underflow if x!=-inf */
 
102
                        FORCE_EVAL((float)(-0x1p-149/x));
 
103
                        if (x < -745.13321910194110842)
 
104
                                return 0;
106
105
                }
107
106
        }
108
107
 
114
113
                        k = 1 - sign - sign;
115
114
                hi = x - k*ln2hi;  /* k*ln2hi is exact here */
116
115
                lo = k*ln2lo;
117
 
                STRICT_ASSIGN(double, x, hi - lo);
 
116
                x = hi - lo;
118
117
        } else if (hx > 0x3e300000)  {  /* if |x| > 2**-28 */
119
118
                k = 0;
120
119
                hi = x;
128
127
        /* x is now in primary range */
129
128
        xx = x*x;
130
129
        c = x - xx*(P1+xx*(P2+xx*(P3+xx*(P4+xx*P5))));
131
 
        x = 1 + (x*c/(2-c) - lo + hi);
 
130
        y = 1 + (x*c/(2-c) - lo + hi);
132
131
        if (k == 0)
133
 
                return x;
134
 
        return scalbn(x, k);
 
132
                return y;
 
133
        return scalbn(y, k);
135
134
}