Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
e_exp.c File Reference
#include "fdlibm.h"

Go to the source code of this file.

Functions

double __ieee754_exp (double x)

Variables

static double one = 1.0
static double halF [2] = {0.5,-0.5,}
static double really_big = 1.0e+300
static double twom1000 = 9.33263618503218878990e-302
static double o_threshold = 7.09782712893383973096e+02
static double u_threshold = -7.45133219101941108420e+02
static double ln2HI [2]
static double ln2LO [2]
static double invln2 = 1.44269504088896338700e+00
static double P1 = 1.66666666666666019037e-01
static double P2 = -2.77777777770155933842e-03
static double P3 = 6.61375632143793436117e-05
static double P4 = -1.65339022054652515390e-06
static double P5 = 4.13813679705723846039e-08

Function Documentation

double __ieee754_exp ( double  x)

Definition at line 143 of file e_exp.c.

{
        fd_twoints u;
       double y,hi,lo,c,t;
       int k, xsb;
       unsigned hx;

        u.d = x;
       hx  = __HI(u);       /* high word of x */
       xsb = (hx>>31)&1;           /* sign bit of x */
       hx &= 0x7fffffff;           /* high word of |x| */

    /* filter out non-finite argument */
       if(hx >= 0x40862E42) {                    /* if |x|>=709.78... */
            if(hx>=0x7ff00000) {
                u.d = x;
              if(((hx&0xfffff)|__LO(u))!=0)
                   return x+x;            /* NaN */
              else return (xsb==0)? x:0.0;       /* exp(+-inf)={inf,0} */
           }
           if(x > o_threshold) return really_big*really_big; /* overflow */
           if(x < u_threshold) return twom1000*twom1000; /* underflow */
       }

    /* argument reduction */
       if(hx > 0x3fd62e42) {              /* if  |x| > 0.5 ln2 */ 
           if(hx < 0x3FF0A2B2) {   /* and |x| < 1.5 ln2 */
              hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
           } else {
              k  = (int)(invln2*x+halF[xsb]);
              t  = k;
              hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
              lo = t*ln2LO[0];
           }
           x  = hi - lo;
       } 
       else if(hx < 0x3e300000)  { /* when |x|<2**-28 */
           if(really_big+x>one) return one+x;/* trigger inexact */
       }
       else k = 0;

    /* x is now in primary range */
       t  = x*x;
       c  = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
       if(k==0)      return one-((x*c)/(c-2.0)-x); 
       else          y = one-((lo-(x*c)/(2.0-c))-hi);
       if(k >= -1021) {
            u.d = y;
           __HI(u) += (k<<20);     /* add k to y's exponent */
            y = u.d;
           return y;
       } else {
            u.d = y;
           __HI(u) += ((k+1000)<<20);/* add k to y's exponent */
            y = u.d;
           return y*twom1000;
       }
}

Here is the caller graph for this function:


Variable Documentation

double halF[2] = {0.5,-0.5,} [static]

Definition at line 123 of file e_exp.c.

double invln2 = 1.44269504088896338700e+00 [static]

Definition at line 132 of file e_exp.c.

double ln2HI[2] [static]
Initial value:
{ 6.93147180369123816490e-01,  
            -6.93147180369123816490e-01,}

Definition at line 128 of file e_exp.c.

double ln2LO[2] [static]
Initial value:
{ 1.90821492927058770002e-10,  
            -1.90821492927058770002e-10,}

Definition at line 130 of file e_exp.c.

double o_threshold = 7.09782712893383973096e+02 [static]

Definition at line 126 of file e_exp.c.

double one = 1.0 [static]

Definition at line 122 of file e_exp.c.

double P1 = 1.66666666666666019037e-01 [static]

Definition at line 133 of file e_exp.c.

double P2 = -2.77777777770155933842e-03 [static]

Definition at line 134 of file e_exp.c.

double P3 = 6.61375632143793436117e-05 [static]

Definition at line 135 of file e_exp.c.

double P4 = -1.65339022054652515390e-06 [static]

Definition at line 136 of file e_exp.c.

double P5 = 4.13813679705723846039e-08 [static]

Definition at line 137 of file e_exp.c.

double really_big = 1.0e+300 [static]

Definition at line 124 of file e_exp.c.

double twom1000 = 9.33263618503218878990e-302 [static]

Definition at line 125 of file e_exp.c.

double u_threshold = -7.45133219101941108420e+02 [static]

Definition at line 127 of file e_exp.c.