Back to index

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

Go to the source code of this file.

Functions

double __ieee754_remainder (double x, double p)

Variables

static double zero = 0.0

Function Documentation

double __ieee754_remainder ( double  x,
double  p 
)

Definition at line 73 of file e_remainder.c.

{
        fd_twoints u;
       int hx,hp;
       unsigned sx,lx,lp;
       double p_half;

        u.d = x;
       hx = __HI(u);        /* high word of x */
       lx = __LO(u);        /* low  word of x */
        u.d = p;
       hp = __HI(u);        /* high word of p */
       lp = __LO(u);        /* low  word of p */
       sx = hx&0x80000000;
       hp &= 0x7fffffff;
       hx &= 0x7fffffff;

    /* purge off exception values */
       if((hp|lp)==0) return (x*p)/(x*p);        /* p = 0 */
       if((hx>=0x7ff00000)||                     /* x not finite */
         ((hp>=0x7ff00000)&&                     /* p is NaN */
         (((hp-0x7ff00000)|lp)!=0)))
           return (x*p)/(x*p);


       if (hp<=0x7fdfffff) x = __ieee754_fmod(x,p+p);   /* now x < 2p */
       if (((hx-hp)|(lx-lp))==0) return zero*x;
       x  = fd_fabs(x);
       p  = fd_fabs(p);
       if (hp<0x00200000) {
           if(x+x>p) {
              x-=p;
              if(x+x>=p) x -= p;
           }
       } else {
           p_half = 0.5*p;
           if(x>p_half) {
              x-=p;
              if(x>=p_half) x -= p;
           }
       }
        u.d = x;
       __HI(u) ^= sx;
        x = u.d;
       return x;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

double zero = 0.0 [static]

Definition at line 66 of file e_remainder.c.