1: #include "../h/rt.h"
2:
3: /*
4: * x - y - subtract y from x.
5: */
6:
7: minus(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 cksub();
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 subtraction using
27: * cksub (to check for overflow) and place the result in arg0 as
28: * the return value.
29: */
30: mkint(cksub(n1.integer, n2.integer), &arg0);
31: else {
32: /*
33: * Either x or y is real, convert the other to a real, perform
34: * the subtraction 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(minus,2,"-")
Defined functions
minus
defined in line
7; used 1 times