|
|
1.1 ! root 1: #include "../h/rt.h" ! 2: ! 3: /* ! 4: * x + y - add x and y. ! 5: */ ! 6: ! 7: plus(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: extern long ckadd(); ! 14: ! 15: SetBound; ! 16: /* ! 17: * x and y must be numeric. Save the cvnum return values for later use. ! 18: */ ! 19: if ((t1 = cvnum(&arg1, &n1)) == NULL) ! 20: runerr(102, &arg1); ! 21: if ((t2 = cvnum(&arg2, &n2)) == NULL) ! 22: runerr(102, &arg2); ! 23: ! 24: if (t1 == T_LONGINT && t2 == T_LONGINT) ! 25: /* ! 26: * Both x and y are integers. Perform integer addition using ! 27: * ckadd (to check for overflow) and place the result in arg0 as ! 28: * the return value. ! 29: */ ! 30: mkint(ckadd(n1.integer, n2.integer), &arg0); ! 31: else { ! 32: /* ! 33: * Either x or y is real, convert the other to a real, perform ! 34: * the addition and place the result in arg0 as the return value. ! 35: */ ! 36: if (t1 == T_LONGINT) ! 37: n1.real = n1.integer; ! 38: if (t2 == T_LONGINT) ! 39: n2.real = n2.integer; ! 40: mkreal(n1.real + n2.real, &arg0); ! 41: } ! 42: ClearBound; ! 43: } ! 44: ! 45: Opblock(plus,2,"+")
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.