Annotation of 42BSD/lib/libc/vax/gen/frexp.c, revision 1.1.1.1

1.1       root        1: /* @(#)frexp.c 4.1 (Berkeley) 12/21/80 */
                      2: /*
                      3:        the call
                      4:                x = frexp(arg,&exp);
                      5:        must return a double fp quantity x which is <1.0
                      6:        and the corresponding binary exponent "exp".
                      7:        such that
                      8:                arg = x*2^exp
                      9: */
                     10: 
                     11: double
                     12: frexp(x,i)
                     13: double x;
                     14: int *i;
                     15: {
                     16:        int neg;
                     17:        int j;
                     18:        j = 0;
                     19:        neg = 0;
                     20:        if(x<0){
                     21:                x = -x;
                     22:                neg = 1;
                     23:                }
                     24:        if(x>1.0)
                     25:                while(x>1){
                     26:                        j = j+1;
                     27:                        x = x/2;
                     28:                        }
                     29:        else if(x<0.5)
                     30:                while(x<0.5){
                     31:                        j = j-1;
                     32:                        x = 2*x;
                     33:                        }
                     34:        *i = j;
                     35:        if(neg) x = -x;
                     36:        return(x);
                     37:        }

unix.superglobalmegacorp.com

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