Annotation of 3BSD/libc/gen/modf.c, revision 1.1.1.1

1.1       root        1: double
                      2: modf(arg,ent)
                      3: double arg;
                      4: double *ent;
                      5: {
                      6:        int neg;
                      7:        int i;
                      8:        double two30 = 1073741824.;
                      9:        double big = 72057594037927936.;  /*2^56*/
                     10:        double x, temp;
                     11:        double ldexp();
                     12:        double frexp();
                     13:        long l;
                     14: 
                     15:        neg = 1;
                     16:        if(arg<0){
                     17:                neg = -1;
                     18:                arg = -arg;
                     19:                }
                     20:        if(arg>big){
                     21:                *ent = neg*arg;
                     22:                return(0);
                     23:                }
                     24:        if(arg<1){
                     25:                *ent = 0;
                     26:                return(neg*arg);
                     27:                }
                     28: 
                     29:        temp = 0;
                     30:        while(arg>two30){
                     31:                x = frexp(arg,&i);
                     32:                if(arg<0.5){
                     33:                        arg = 2*arg;
                     34:                        i = i-1;
                     35:                        }
                     36:                x = ldexp(0.5,i);
                     37:                arg = arg - x;
                     38:                temp = temp + x;
                     39:                }
                     40: 
                     41:        l = arg;
                     42:        arg = arg-l;
                     43:        temp = temp+l;
                     44:        *ent = neg*temp;
                     45:        return(neg*arg);
                     46:        }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.