1: #include "../h/rt.h"
   2: 
   3: /*
   4:  * x * y - multiply x and y.
   5:  */
   6: 
   7: mult(nargs, arg2, arg1, arg0)
   8: int nargs;
   9: struct descrip arg2, arg1, arg0;
  10:    {
  11:    register int t1, t2;
  12:    union numeric n1, n2;
  13: 
  14:    SetBound;
  15:    /*
  16:     * x and y must be numeric.  Save the cvnum return values for later use.
  17:     */
  18:    if ((t1 = cvnum(&arg1, &n1)) == NULL)
  19:       runerr(102, &arg1);
  20:    if ((t2 = cvnum(&arg2, &n2)) == NULL)
  21:       runerr(102, &arg2);
  22: 
  23:    if (t1 == T_LONGINT && t2 == T_LONGINT)
  24:       /*
  25:        * Both x and y are integers.  Perform the multiplication and
  26:        *  and place the result in arg0 as the return value.
  27:        */
  28:       mkint(n1.integer * n2.integer, &arg0);
  29:    else {
  30:       /*
  31:        * Either x or y is real, convert the other to a real, perform
  32:        *  the subtraction and place the result in arg0 as the return value.
  33:        */
  34:       if (t1 == T_LONGINT)
  35:          n1.real = n1.integer;
  36:       if (t2 == T_LONGINT)
  37:          n2.real = n2.integer;
  38:       mkreal(n1.real * n2.real, &arg0);
  39:       }
  40:    ClearBound;
  41:    }
  42: 
  43: Opblock(mult,2,"*")

Defined functions

mult defined in line 7; used 1 times
  • in line 43
Last modified: 1984-11-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 664
Valid CSS Valid XHTML 1.0 Strict