|
|
1.1 ! root 1: #include <math.h> ! 2: #include <errno.h> ! 3: extern int errno; ! 4: double errcheck(); ! 5: ! 6: double Log(x) ! 7: double x; ! 8: { ! 9: return errcheck(log(x), "log"); ! 10: } ! 11: double Log10(x) ! 12: double x; ! 13: { ! 14: return errcheck(log10(x), "log10"); ! 15: } ! 16: ! 17: double Sqrt(x) ! 18: double x; ! 19: { ! 20: return errcheck(sqrt(x), "sqrt"); ! 21: } ! 22: ! 23: double Gamma(x) ! 24: double x; ! 25: { ! 26: double y; ! 27: extern int signgam; ! 28: y=errcheck(gamma(x), "gamma"); ! 29: if(y>88.0) ! 30: execerror("gamma result out of range", (char *)0); ! 31: return signgam*exp(y); ! 32: } ! 33: ! 34: double Exp(x) ! 35: double x; ! 36: { ! 37: return errcheck(exp(x), "exp"); ! 38: } ! 39: ! 40: double Pow(x, y) ! 41: double x, y; ! 42: { ! 43: return errcheck(pow(x,y), "exponentiation"); ! 44: } ! 45: ! 46: double integer(x) ! 47: double x; ! 48: { ! 49: return (double)(long)x; ! 50: } ! 51: ! 52: double errcheck(d, s) /* check result of library call */ ! 53: double d; ! 54: char *s; ! 55: { ! 56: if (errno == EDOM) { ! 57: errno = 0; ! 58: execerror(s, "argument out of domain"); ! 59: } else if (errno == ERANGE) { ! 60: errno = 0; ! 61: execerror(s, "result out of range"); ! 62: } ! 63: return d; ! 64: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.