Annotation of OpenXM_contrib2/asir2000/builtin/round.c, Revision 1.2
1.2 ! noro 1: /* $OpenXM$ */
! 2:
1.1 noro 3: #define INTERVAL
4: #include "ca.h"
5: #include "parse.h"
6: #include "interval.h"
7:
8: void Padd_pinf(),Padd_minf();
9: void Psub_pinf(),Psub_minf();
10: void Pmul_pinf(),Pmul_minf();
11: void Pdiv_pinf(),Pdiv_minf();
12:
13: struct ftab round_tab[] = {
14: {"add_pinf",Padd_pinf,2},
15: {"add_minf",Padd_minf,2},
16: {"sub_pinf",Psub_pinf,2},
17: {"sub_minf",Psub_minf,2},
18: {"mul_pinf",Pmul_pinf,2},
19: {"mul_minf",Pmul_minf,2},
20: {"div_pinf",Pdiv_pinf,2},
21: {"div_minf",Pdiv_minf,2},
22: {0,0,0},
23: };
24:
25: void Padd_pinf(NODE arg,Real *rp)
26: {
27: Real a,b,r;
28: double c;
29:
30: a = (Real)ARG0(arg);
31: b = (Real)ARG1(arg);
32: if ( !a )
33: *rp = b;
34: else if ( !b )
35: *rp = a;
36: else {
37: FPPLUSINF
38: c = BDY(a)+BDY(b);
39: FPNEAREST
40: MKReal(c,r);
41: *rp = r;
42: }
43: }
44:
45: void Padd_minf(NODE arg,Real *rp)
46: {
47: Real a,b,r;
48: double c;
49:
50: a = (Real)ARG0(arg);
51: b = (Real)ARG1(arg);
52: if ( !a )
53: *rp = b;
54: else if ( !b )
55: *rp = a;
56: else {
57: FPMINUSINF
58: c = BDY(a)+BDY(b);
59: FPNEAREST
60: MKReal(c,r);
61: *rp = r;
62: }
63: }
64:
65: void Psub_pinf(NODE arg,Real *rp)
66: {
67: Real a,b,r;
68: double c;
69:
70: a = (Real)ARG0(arg);
71: b = (Real)ARG1(arg);
72: if ( !a ) {
73: if ( !b )
74: *rp = 0;
75: else {
76: c = -BDY(b);
77: MKReal(c,r);
78: *rp = r;
79: }
80: } else if ( !b )
81: *rp = a;
82: else {
83: FPPLUSINF
84: c = BDY(a)-BDY(b);
85: FPNEAREST
86: MKReal(c,r);
87: *rp = r;
88: }
89: }
90:
91: void Psub_minf(NODE arg,Real *rp)
92: {
93: Real a,b,r;
94: double c;
95:
96: a = (Real)ARG0(arg);
97: b = (Real)ARG1(arg);
98: if ( !a ) {
99: if ( !b )
100: *rp = 0;
101: else {
102: c = -BDY(b);
103: MKReal(c,r);
104: *rp = r;
105: }
106: } else if ( !b )
107: *rp = a;
108: else {
109: FPMINUSINF
110: c = BDY(a)-BDY(b);
111: FPNEAREST
112: MKReal(c,r);
113: *rp = r;
114: }
115: }
116:
117: void Pmul_pinf(NODE arg,Real *rp)
118: {
119: Real a,b,r;
120: double c;
121:
122: a = (Real)ARG0(arg);
123: b = (Real)ARG1(arg);
124: if ( !a || !b )
125: *rp = 0;
126: else {
127: FPPLUSINF
128: c = BDY(a)*BDY(b);
129: FPNEAREST
130: MKReal(c,r);
131: *rp = r;
132: }
133: }
134:
135: void Pmul_minf(NODE arg,Real *rp)
136: {
137: Real a,b,r;
138: double c;
139:
140: a = (Real)ARG0(arg);
141: b = (Real)ARG1(arg);
142: if ( !a || !b )
143: *rp = 0;
144: else {
145: FPMINUSINF
146: c = BDY(a)*BDY(b);
147: FPNEAREST
148: MKReal(c,r);
149: *rp = r;
150: }
151: }
152:
153: void Pdiv_pinf(NODE arg,Real *rp)
154: {
155: Real a,b,r;
156: double c;
157:
158: a = (Real)ARG0(arg);
159: b = (Real)ARG1(arg);
160: if ( !b )
161: error("div_pinf : division by 0");
162: else if ( !a )
163: *rp = 0;
164: else {
165: FPPLUSINF
166: c = BDY(a)/BDY(b);
167: FPNEAREST
168: MKReal(c,r);
169: *rp = r;
170: }
171: }
172:
173: void Pdiv_minf(NODE arg,Real *rp)
174: {
175: Real a,b,r;
176: double c;
177:
178: a = (Real)ARG0(arg);
179: b = (Real)ARG1(arg);
180: if ( !b )
181: error("div_pinf : division by 0");
182: else if ( !a )
183: *rp = 0;
184: else {
185: FPMINUSINF
186: c = BDY(a)/BDY(b);
187: FPNEAREST
188: MKReal(c,r);
189: *rp = r;
190: }
191: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>