File:  [CSRG BSD Unix] / 43BSD / contrib / icon / rt / pow.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#include   <errno.h>
int errno;
double log(), exp();
/*
 * pow - calculate arg1^arg2.
 */
double
pow(arg1,arg2)
double arg1, arg2;
   {
   double temp;
   long l;

   if(arg1 <= 0.) {
      if(arg1 == 0.) {
         if(arg2 <= 0.)
            goto domain;
         return(0.);
      }
      l = arg2;
      if(l != arg2)
         goto domain;
      temp = exp(arg2 * log(-arg1));
      if(l & 1)
         temp = -temp;
      return(temp);
   }
   return(exp(arg2 * log(arg1)));

domain:
   errno = EDOM;
   return(0.);
   }

unix.superglobalmegacorp.com

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