Back to index

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

Go to the source code of this file.

Functions

double fd_scalbn (double x, int n)

Variables

static double two54 = 1.80143985094819840000e+16
static double twom54 = 5.55111512312578270212e-17
static double really_big = 1.0e+300
static double tiny = 1.0e-300

Function Documentation

double fd_scalbn ( double  x,
int  n 
)

Definition at line 74 of file s_scalbn.c.

{
        fd_twoints u;
       int  k,hx,lx;
        u.d = x;
       hx = __HI(u);
       lx = __LO(u);
        k = (hx&0x7ff00000)>>20;          /* extract exponent */
        if (k==0) {                       /* 0 or subnormal x */
            if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
           x *= two54;
            u.d = x;
           hx = __HI(u);
           k = ((hx&0x7ff00000)>>20) - 54; 
            if (n< -50000) return tiny*x;        /*underflow*/
           }
        if (k==0x7ff) return x+x;         /* NaN or Inf */
        k = k+n; 
        if (k >  0x7fe) return really_big*fd_copysign(really_big,x); /* overflow  */
        if (k > 0)                        /* normal result */
           {u.d = x; __HI(u) = (hx&0x800fffff)|(k<<20); x = u.d; return x;}
        if (k <= -54) {
            if (n > 50000)  /* in case integer overflow in n+k */
              return really_big*fd_copysign(really_big,x);     /*overflow*/
           else return tiny*fd_copysign(tiny,x);        /*underflow*/
        }
        k += 54;                          /* subnormal result */
        u.d = x;
        __HI(u) = (hx&0x800fffff)|(k<<20);
        x = u.d;
        return x*twom54;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

double really_big = 1.0e+300 [static]

Definition at line 68 of file s_scalbn.c.

double tiny = 1.0e-300 [static]

Definition at line 69 of file s_scalbn.c.

double two54 = 1.80143985094819840000e+16 [static]

Definition at line 66 of file s_scalbn.c.

double twom54 = 5.55111512312578270212e-17 [static]

Definition at line 67 of file s_scalbn.c.