1: /*
   2: #	MATH(3.icon)
   3: #
   4: #	Miscellaneous math functions
   5: #
   6: #	Ralph E. Griswold
   7: #
   8: #	Last modified 8/19/84
   9: #
  10: */
  11: 
  12: #include "../h/rt.h"
  13: #include <errno.h>
  14: 
  15: int errno;
  16: /*
  17:  * exp(x), x in radians
  18:  */
  19: Xexp(nargs, arg1, arg0)
  20: int nargs;
  21: struct descrip arg1, arg0;
  22:    {
  23:    int t;
  24:    double y;
  25:    union numeric r;
  26:    double exp();
  27: 
  28:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
  29:    y = exp(r.real);
  30:    if (errno == ERANGE) runerr(252, NULL);
  31:    mkreal(y,&arg0);
  32:    }
  33: Procblock(exp,1)
  34: 
  35: /*
  36:  * log(x), x in radians
  37:  */
  38: Xlog(nargs, arg1, arg0)
  39: int nargs;
  40: struct descrip arg1, arg0;
  41:    {
  42:    int t;
  43:    double y;
  44:    union numeric r;
  45:    double log();
  46: 
  47:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
  48:    y = log(r.real);
  49:    if (errno == EDOM) runerr(251, NULL);
  50:    mkreal(y,&arg0);
  51:    }
  52: Procblock(log,1)
  53: 
  54: /*
  55:  * log10(x), x in radians
  56:  */
  57: Xlog10(nargs, arg1, arg0)
  58: int nargs;
  59: struct descrip arg1, arg0;
  60:    {
  61:    int t;
  62:    double y;
  63:    union numeric r;
  64:    double log10();
  65: 
  66:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
  67:    y = log10(r.real);
  68:    if (errno == EDOM) runerr(251, NULL);
  69:    mkreal(y,&arg0);
  70:    }
  71: Procblock(log10,1)
  72: 
  73: /*
  74:  * sqrt(x), x in radians
  75:  */
  76: Xsqrt(nargs, arg1, arg0)
  77: int nargs;
  78: struct descrip arg1, arg0;
  79:    {
  80:    int t;
  81:    double y;
  82:    union numeric r;
  83:    double sqrt();
  84: 
  85:    if ((t = cvreal(&arg1, &r)) == NULL) runerr(102, &arg1);
  86:    y = sqrt(r.real);
  87:    if (errno == EDOM) runerr(251, NULL);
  88:    mkreal(y,&arg0);
  89:    }
  90: Procblock(sqrt,1)

Defined functions

Procblock defined in line 71; never used
Xexp defined in line 19; never used
Xlog defined in line 33; never used
Xlog10 defined in line 52; never used
Xsqrt defined in line 71; never used

Defined variables

errno defined in line 15; used 4 times
Last modified: 1984-08-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 854
Valid CSS Valid XHTML 1.0 Strict