79
|
1 #include "stdio.h"
|
|
2
|
472
|
3 void test8();
|
82
|
4 void print(double d);
|
79
|
5
|
81
|
6 extern double sin(double);
|
84
|
7 // extern float fsin(float);
|
471
|
8 double test9(double f,int i);
|
81
|
9
|
82
|
10 float f = 0.3;
|
|
11 double d = 0.3;
|
|
12 float f1 = 0.3;
|
|
13 double d1 = 0.3;
|
84
|
14 double d2 = -0.2;
|
96
|
15 float h = 1.0;
|
82
|
16
|
91
|
17 int
|
|
18 d2i(double d) {
|
|
19 return (int)d;
|
|
20 }
|
|
21
|
|
22 double
|
|
23 i2d(int u) {
|
|
24 return (double)u;
|
|
25 }
|
90
|
26
|
91
|
27 unsigned u;
|
|
28 unsigned
|
|
29 d2u(double d) {
|
|
30 return (unsigned)d;
|
|
31 }
|
|
32
|
|
33 double
|
|
34 u2d(unsigned u) {
|
|
35 return (double)u;
|
90
|
36 }
|
|
37
|
379
|
38 double
|
|
39 f2d(float u) {
|
|
40 double u1;
|
|
41 u1 = f1;
|
|
42 return (double)u;
|
|
43 }
|
|
44
|
|
45 float
|
|
46 d2f(double u) {
|
|
47 float u1;
|
|
48 u1 = d1;
|
|
49 return (float)u;
|
|
50 }
|
|
51
|
471
|
52 void
|
|
53 test1(float id, float x,float y,float sx,float sy,int behav)
|
|
54 {
|
|
55 printf("%f %f %f %f %f %d\n", id,x,y,sx,sy,behav);
|
|
56 }
|
|
57
|
|
58 void
|
|
59 test2(int id, int x,float y,float sx,float sy,int behav)
|
|
60 {
|
|
61 printf("%d %d %f %f %f %d\n", id,x,y,sx,sy,behav);
|
|
62 }
|
|
63
|
|
64 void
|
|
65 test3(int id, float x,float y,float sx,float sy,int behav)
|
|
66 {
|
|
67 printf("%d %f %f %f %f %d\n", id,x,y,sx,sy,behav);
|
|
68 }
|
|
69
|
|
70 void
|
|
71 test4(int id, float x,int y,float sx,float sy,int behav)
|
|
72 {
|
|
73 printf("%d %f %d %f %f %d\n", id,x,y,sx,sy,behav);
|
|
74 }
|
|
75
|
|
76 void
|
|
77 test5(float id, int x,float y,int sx,float sy,int behav)
|
|
78 {
|
|
79 printf("%f %d %f %d %f %d\n", id,x,y,sx,sy,behav);
|
|
80 }
|
|
81
|
|
82
|
|
83
|
79
|
84 int
|
|
85 main(int ac,char *av[]) {
|
82
|
86 double g;
|
|
87 int i;
|
85
|
88 unsigned u;
|
108
|
89 double d00 = ac?0.5:3;
|
|
90
|
427
|
91 printf("#0058:%g\n",d00);
|
82
|
92
|
471
|
93 test1(1,2,3,10,11,4);
|
|
94 test2(1,2,3,10,11,4);
|
|
95 test3(1,2,3,10,11,4);
|
|
96 test4(1,2,3,10,11,4);
|
|
97 test5(1,2,3,10,11,4);
|
|
98
|
82
|
99 g = 1.0;
|
|
100 g = -g;
|
427
|
101 printf("#0062:%d\ncond0 ",1);
|
|
102 if(f==f*1.0) printf("#0063:t ");
|
|
103 printf("#0064:%d\ncond1 ",f==f*1.0);
|
|
104 if(d==f*1.0) printf("#0065:t ");
|
|
105 printf("#0066:%d\ncond2 ",d==f*1.0);
|
|
106 if(f==f1) printf("#0067:t ");
|
|
107 printf("#0068:%d\ncond3 ",f==f1);
|
|
108 if(d==d1) printf("#0069:t ");
|
|
109 printf("#0070:%d\ncond4 ",d==d2);
|
|
110 if(d==d2) printf("#0071:t ");
|
|
111 printf("#0072:%d\ncond5 ",(d==d2));
|
|
112 if(d>d1) printf("#0073:t ");
|
|
113 printf("#0074:%d\ncond6 ",d>d1);
|
|
114 if(d>d2) printf("#0075:t ");
|
|
115 printf("#0076:%d\ncond7 ",d>d2);
|
|
116 if(d>=d1) printf("#0077:t ");
|
|
117 printf("#0078:%d\ncond8 ",d>=d1);
|
|
118 if(d>=d2) printf("#0079:t ");
|
|
119 printf("#0080:%d\ncond9 ",d>=d2);
|
|
120 if(d!=d1) printf("#0081:t ");
|
|
121 printf("#0082:%d\ncond10 ",d!=d1);
|
|
122 if(d!=d2) printf("#0083:5 ");
|
|
123 printf("#0084:%d\ncond11 ",d!=d2);
|
|
124 if(d<d1) printf("#0085:t ");
|
|
125 printf("#0086:%d\ncond12 ",d<d1);
|
|
126 if(d<d2) printf("#0087:t ");
|
|
127 printf("#0088:%d\ncond13 ",d<d2);
|
|
128 if(d<=d1) printf("#0089:t ");
|
|
129 printf("#0090:%d\ncond14 ",d<=d1);
|
|
130 if(d<=d2) printf("#0091:t ");
|
|
131 printf("#0092:%d\ncond15 ",d<=d2);
|
85
|
132 d = 123.4234; f=-234.333;
|
82
|
133 i = d;
|
|
134 d = i;
|
|
135 i = f;
|
|
136 f = i;
|
427
|
137 printf("#0098:\ni=%d d=%g f=%f",i,d,f);
|
94
|
138 f = g = d = d1 = d2 = f;
|
427
|
139 printf("#0100: i=%d d=%g f=%f g=%g\n",i,d,f,g);
|
82
|
140
|
86
|
141 d = 4204967294.4234; f=4204967294.4234;
|
85
|
142 u = d;
|
427
|
143 printf("#0104:1: u=%u d=%g f=%f\n",u,d,f);
|
85
|
144 d = u;
|
427
|
145 printf("#0106:2: u=%u d=%g f=%f\n",u,d,f);
|
85
|
146 u = f;
|
427
|
147 printf("#0108:3: u=%u d=%g f=%f\n",u,d,f);
|
85
|
148 f = u;
|
427
|
149 printf("#0110:4: u=%u d=%g f=%f\n",u,d,f);
|
85
|
150
|
82
|
151 print(1.0);
|
|
152 print(0.1234);
|
|
153 print(1.234e10);
|
|
154 print(1.234e-10);
|
|
155
|
472
|
156 test8();
|
471
|
157 printf("#0118:nested call: %g\n",test9(test9(test9(test9(-0.333,3),5),6),7));
|
79
|
158 return 0;
|
|
159 }
|
|
160
|
82
|
161 void
|
|
162 print(double d)
|
|
163 {
|
|
164 float f;
|
|
165 int *dd;
|
|
166
|
|
167 f = d;
|
|
168
|
|
169 dd = (int*) &d;
|
427
|
170 printf("#0131:d %g ",d);
|
|
171 printf("#0132:dx %08x %08x\n",*(dd),*(dd+1));
|
82
|
172
|
|
173 dd = (int*) &f;
|
427
|
174 printf("#0135:f %g ",f);
|
|
175 printf("#0136:dx %08x \n",*(dd));
|
82
|
176 }
|
|
177
|
81
|
178 double
|
|
179 testd(double i,double j)
|
|
180 {
|
87
|
181 return j+1.1+.0e3+12.3e-12;
|
81
|
182 }
|
|
183
|
|
184 float
|
|
185 testf(float i,float j)
|
|
186 {
|
87
|
187 return j+1;
|
81
|
188 }
|
|
189
|
79
|
190 void
|
472
|
191 test8()
|
79
|
192 {
|
|
193 float f;
|
|
194 float f1;
|
|
195 double g;
|
|
196 double g1;
|
85
|
197 float *pf;
|
|
198 float *pf1;
|
|
199 double *pg;
|
|
200 double *pg1;
|
|
201 int n = 1;
|
79
|
202
|
427
|
203 printf("#0164:simple double ");
|
79
|
204 f = 1.3;
|
|
205
|
|
206 g = 1.0;
|
|
207 g = g+g;
|
427
|
208 printf("#0169:%d:%g\t",n++,g);
|
79
|
209 g1 = g*g;
|
427
|
210 printf("#0171:%d:%g\t",n++,g1);
|
79
|
211 g = g/g1;
|
427
|
212 printf("#0173:%d:%g\t",n++,g);
|
79
|
213 g = g-g1;
|
427
|
214 printf("#0175:%d:%g\t",n++,g);
|
79
|
215 g = sin(g1);
|
427
|
216 printf("#0177:%d:%g\t",n++,g);
|
81
|
217 g = testd(g,g1);
|
427
|
218 printf("#0179:%d:%g\t",n++,g);
|
|
219 printf("#0180:\n");
|
79
|
220
|
427
|
221 printf("#0182:simple float ");
|
79
|
222 f = f+f;
|
427
|
223 printf("#0184:%d:%g\t",n++,f);
|
79
|
224 f1 = f*f;
|
427
|
225 printf("#0186:%d:%g\t",n++,f1);
|
79
|
226 f = f/f1;
|
427
|
227 printf("#0188:%d:%g\t",n++,f);
|
79
|
228 f = f-f1;
|
427
|
229 printf("#0190:%d:%g\t",n++,f);
|
79
|
230 f = sin(f1);
|
427
|
231 printf("#0192:%d:%g\t",n++,f);
|
|
232 printf("#0193:\n");
|
85
|
233
|
427
|
234 printf("#0195:post/pre increment ");
|
86
|
235 g1 = g;
|
427
|
236 printf("#0197:%d:%g\t",n++,g1++ - ++g);
|
85
|
237
|
86
|
238 f1 = f;
|
427
|
239 printf("#0200:%d:%g\t",n++,f1++ - ++f);
|
87
|
240
|
|
241 g1 = g;
|
427
|
242 printf("#0203:%d:%g\t",n++,g1-- - --g);
|
87
|
243
|
|
244 f1 = f;
|
427
|
245 printf("#0206:%d:%g\t",n++,f1-- - --f);
|
87
|
246
|
427
|
247 printf("#0208:\n");
|
|
248 printf("#0209:simple calc ");
|
87
|
249
|
|
250 f=0.13; g=-0.56; f1=-0.13; g1=0.56;
|
79
|
251
|
|
252 g = f+f;
|
427
|
253 printf("#0214:%d:%g\t",n++,g);
|
79
|
254 f = g*g;
|
427
|
255 printf("#0216:%d:%g\t",n++,f);
|
79
|
256 g = g*g+f*f-g1*g1;
|
427
|
257 printf("#0218:%d:%g\t",n++,g);
|
|
258 printf("#0219:\n");
|
79
|
259
|
427
|
260 printf("#0221:float argument ");
|
87
|
261 f = testf(f,f1);
|
427
|
262 printf("#0223:%d:%g\t",n++,f);
|
87
|
263
|
427
|
264 printf("#0225:\nindirect ");
|
85
|
265 n=1;
|
|
266 f = 1.3; pf=&f; pf1=&f1;
|
|
267
|
|
268 g = 1.0; pg=&g; pg1=&g1;
|
|
269 *pg = *pg+ *pg;
|
427
|
270 printf("#0231:%d:%g\t",n++,*pg);
|
85
|
271 *pg1 = *pg**pg;
|
427
|
272 printf("#0233:%d:%g\t",n++,*pg1);
|
85
|
273 *pg = *pg/ *pg1;
|
427
|
274 printf("#0235:%d:%g\t",n++,*pg);
|
85
|
275 *pg = *pg-*pg1;
|
427
|
276 printf("#0237:%d:%g\t",n++,*pg);
|
85
|
277 *pg = sin(*pg1);
|
427
|
278 printf("#0239:%d:%g\t",n++,*pg);
|
85
|
279 *pg = testd(*pg,*pg1);
|
427
|
280 printf("#0241:%d:%g\t",n++,*pg);
|
|
281 printf("#0242:\n");
|
85
|
282
|
|
283 *pf = *pf+*pf;
|
427
|
284 printf("#0245:%d:%g\t",n++,*pf);
|
85
|
285 *pf1 = *pf**pf;
|
427
|
286 printf("#0247:%d:%g\t",n++,*pf1);
|
85
|
287 *pf = *pf/ *pf1;
|
427
|
288 printf("#0249:%d:%g\t",n++,*pf);
|
85
|
289 *pf = *pf-*pf1;
|
427
|
290 printf("#0251:%d:%g\t",n++,*pf);
|
85
|
291 *pf = sin(*pf1);
|
427
|
292 printf("#0253:%d:%g\t",n++,*pf);
|
|
293 printf("#0254:\n");
|
85
|
294
|
427
|
295 printf("#0256:indirect post/pre ");
|
86
|
296 *pg1 = *pg;
|
427
|
297 printf("#0258:%d:%g\t",n++,(*pg1)++ - ++(*pg));
|
85
|
298
|
86
|
299 *pf1 = *pf;
|
427
|
300 printf("#0261:%d:%g\t",n++,(*pf1)++ - ++(*pf));
|
87
|
301
|
|
302 *pg1 = *pg;
|
427
|
303 printf("#0264:%d:%g\t",n++, (*pg1)-- - --(*pg));
|
86
|
304
|
87
|
305 *pf1 = *pf;
|
427
|
306 printf("#0267:%d:%g\t",n++, (*pf1)-- - --(*pf));
|
|
307 printf("#0268:\n");
|
87
|
308
|
|
309 *pf=0.13; *pg=-0.56; *pf1=-0.13; *pg1=0.56;
|
85
|
310
|
|
311 *pg = *pf+*pf;
|
427
|
312 printf("#0273:%d:%g\t",n++,*pg);
|
85
|
313 *pf = *pg**pg;
|
427
|
314 printf("#0275:%d:%g\t",n++,*pf);
|
85
|
315 *pg = *pg**pg+*pf**pf-*pg1**pg1;
|
427
|
316 printf("#0277:%d:%g\t",n++,*pg);
|
|
317 printf("#0278:\n");
|
85
|
318
|
427
|
319 printf("#0280:float argument ");
|
87
|
320
|
|
321 *pf = testf(*pf,*pf1);
|
427
|
322 printf("#0283:%d:%g\t",n++,*pf);
|
87
|
323
|
|
324
|
427
|
325 printf("#0286:\nassop ");
|
85
|
326 n=1;
|
|
327 f = 1.3;
|
|
328 g = 1.0;
|
|
329
|
|
330 g *= 2*g;
|
427
|
331 printf("#0292:%d:%g\t",n++,g);
|
85
|
332 g /= 2*g;
|
427
|
333 printf("#0294:%d:%g\t",n++,g);
|
85
|
334 g -= 2*g;
|
427
|
335 printf("#0296:%d:%g\t",n++,g);
|
85
|
336 g += 2*g;
|
427
|
337 printf("#0298:%d:%g\t",n++,g);
|
85
|
338
|
|
339 f *= 2*g;
|
427
|
340 printf("#0301:%d:%g\t",n++,f);
|
85
|
341 f /= 2*g;
|
427
|
342 printf("#0303:%d:%g\t",n++,f);
|
85
|
343 f -= 2*g;
|
427
|
344 printf("#0305:%d:%g\t",n++,f);
|
85
|
345 f += 2*g;
|
427
|
346 printf("#0307:%d:%g\t",n++,f);
|
|
347 printf("#0308:\n");
|
85
|
348
|
|
349 n=1;
|
|
350 f = 1.3;
|
|
351 g = 1.0;
|
|
352
|
427
|
353 printf("#0314:indirect assop ");
|
85
|
354 *pg *= 2**pg;
|
427
|
355 printf("#0316:%d:%g\t",n++,*pg);
|
85
|
356 *pg /= 2**pg;
|
427
|
357 printf("#0318:%d:%g\t",n++,*pg);
|
85
|
358 *pg -= 2**pg;
|
427
|
359 printf("#0320:%d:%g\t",n++,*pg);
|
85
|
360 *pg += 2**pg;
|
427
|
361 printf("#0322:%d:%g\t",n++,*pg);
|
85
|
362
|
|
363 *pf *= 2**pg;
|
427
|
364 printf("#0325:%d:%g\t",n++,*pf);
|
85
|
365 *pf /= 2**pg;
|
427
|
366 printf("#0327:%d:%g\t",n++,*pf);
|
85
|
367 *pf -= 2**pg;
|
427
|
368 printf("#0329:%d:%g\t",n++,*pf);
|
85
|
369 *pf += 2**pg;
|
427
|
370 printf("#0331:%d:%g\t",n++,*pf);
|
|
371 printf("#0332:\n");
|
85
|
372
|
|
373
|
79
|
374 return;
|
|
375 }
|
94
|
376
|
|
377 double
|
|
378 test2(double f,int i)
|
|
379 {
|
|
380 double g,h;
|
|
381
|
|
382 if (i<=0) return f;
|
112
|
383 #if 1
|
427
|
384 printf("#0345:rec: %d %g\n",i,f);
|
112
|
385 #endif
|
94
|
386 g = f*2;
|
|
387 h = f-0.5;
|
|
388 return h/3-(3.0-(g+3)*test2(f*0.5,i-1)/(h-1));
|
|
389 }
|
471
|
390
|
|
391
|