Annotation of 43BSD/contrib/icon/rt/pow.c, revision 1.1

1.1     ! root        1: #include   <errno.h>
        !             2: int errno;
        !             3: double log(), exp();
        !             4: /*
        !             5:  * pow - calculate arg1^arg2.
        !             6:  */
        !             7: double
        !             8: pow(arg1,arg2)
        !             9: double arg1, arg2;
        !            10:    {
        !            11:    double temp;
        !            12:    long l;
        !            13: 
        !            14:    if(arg1 <= 0.) {
        !            15:       if(arg1 == 0.) {
        !            16:          if(arg2 <= 0.)
        !            17:             goto domain;
        !            18:          return(0.);
        !            19:       }
        !            20:       l = arg2;
        !            21:       if(l != arg2)
        !            22:          goto domain;
        !            23:       temp = exp(arg2 * log(-arg1));
        !            24:       if(l & 1)
        !            25:          temp = -temp;
        !            26:       return(temp);
        !            27:    }
        !            28:    return(exp(arg2 * log(arg1)));
        !            29: 
        !            30: domain:
        !            31:    errno = EDOM;
        !            32:    return(0.);
        !            33:    }

unix.superglobalmegacorp.com

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