|
|
1.1 ! root 1: /* ! 2: * MATH ! 3: * ! 4: * Miscellaneous math functions. ! 5: * ! 6: * Ralph E. Griswold ! 7: * ! 8: * Last modified 5/2/86 ! 9: * ! 10: */ ! 11: ! 12: #include "../h/rt.h" ! 13: #include <errno.h> ! 14: ! 15: int errno; ! 16: /* ! 17: * exp(x) ! 18: */ ! 19: FncDcl(exp,1) ! 20: { ! 21: int t; ! 22: double y; ! 23: union numeric r; ! 24: double exp(); ! 25: ! 26: if ((t = cvreal(&Arg1, &r)) == NULL) runerr(102, &Arg1); ! 27: y = exp(r.real); ! 28: if (errno == ERANGE) runerr(252, NULL); ! 29: mkreal(y,&Arg0); ! 30: Return; ! 31: } ! 32: ! 33: /* ! 34: * log(x) ! 35: */ ! 36: FncDcl(log,1) ! 37: { ! 38: int t; ! 39: double y; ! 40: union numeric r; ! 41: double log(); ! 42: ! 43: if ((t = cvreal(&Arg1, &r)) == NULL) runerr(102, &Arg1); ! 44: y = log(r.real); ! 45: if (errno == EDOM) runerr(251, NULL); ! 46: mkreal(y,&Arg0); ! 47: Return; ! 48: } ! 49: ! 50: /* ! 51: * log10(x) ! 52: */ ! 53: FncDcl(log10,1) ! 54: { ! 55: int t; ! 56: double y; ! 57: union numeric r; ! 58: double log10(); ! 59: ! 60: if ((t = cvreal(&Arg1, &r)) == NULL) runerr(102, &Arg1); ! 61: y = log10(r.real); ! 62: if (errno == EDOM) runerr(251, NULL); ! 63: mkreal(y,&Arg0); ! 64: Return; ! 65: } ! 66: ! 67: /* ! 68: * sqrt(x) ! 69: */ ! 70: FncDcl(sqrt,1) ! 71: { ! 72: int t; ! 73: double y; ! 74: union numeric r; ! 75: double sqrt(); ! 76: ! 77: if ((t = cvreal(&Arg1, &r)) == NULL) runerr(102, &Arg1); ! 78: y = sqrt(r.real); ! 79: if (errno == EDOM) runerr(251, NULL); ! 80: mkreal(y,&Arg0); ! 81: Return; ! 82: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.