|
|
1.1 ! root 1: /* @(#)pow.c 4.2 6/30/83 */ ! 2: ! 3: /* ! 4: computes a^b. ! 5: uses log and exp ! 6: */ ! 7: ! 8: #include <errno.h> ! 9: int errno; ! 10: double log(), exp(); ! 11: ! 12: double ! 13: pow(arg1,arg2) ! 14: double arg1, arg2; ! 15: { ! 16: double temp; ! 17: long l; ! 18: ! 19: #ifdef vax ! 20: asm(" bispsw $0xe0"); ! 21: #endif ! 22: if(arg1 <= 0.) { ! 23: if(arg1 == 0.) { ! 24: if(arg2 <= 0.) ! 25: goto domain; ! 26: return(0.); ! 27: } ! 28: l = arg2; ! 29: if(l != arg2) ! 30: goto domain; ! 31: temp = exp(arg2 * log(-arg1)); ! 32: if(l & 1) ! 33: temp = -temp; ! 34: return(temp); ! 35: } ! 36: return(exp(arg2 * log(arg1))); ! 37: ! 38: domain: ! 39: errno = EDOM; ! 40: return(0.); ! 41: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.