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);
|
479
|
9 int test7();
|
81
|
10
|
82
|
11 float f = 0.3;
|
|
12 double d = 0.3;
|
|
13 float f1 = 0.3;
|
|
14 double d1 = 0.3;
|
84
|
15 double d2 = -0.2;
|
96
|
16 float h = 1.0;
|
82
|
17
|
91
|
18 int
|
|
19 d2i(double d) {
|
|
20 return (int)d;
|
|
21 }
|
|
22
|
|
23 double
|
|
24 i2d(int u) {
|
|
25 return (double)u;
|
|
26 }
|
90
|
27
|
91
|
28 unsigned u;
|
|
29 unsigned
|
|
30 d2u(double d) {
|
|
31 return (unsigned)d;
|
|
32 }
|
|
33
|
|
34 double
|
|
35 u2d(unsigned u) {
|
|
36 return (double)u;
|
90
|
37 }
|
|
38
|
379
|
39 double
|
|
40 f2d(float u) {
|
|
41 double u1;
|
|
42 u1 = f1;
|
|
43 return (double)u;
|
|
44 }
|
|
45
|
|
46 float
|
|
47 d2f(double u) {
|
|
48 float u1;
|
|
49 u1 = d1;
|
|
50 return (float)u;
|
|
51 }
|
|
52
|
471
|
53 void
|
|
54 test1(float id, float x,float y,float sx,float sy,int behav)
|
|
55 {
|
491
|
56 printf("#0055:%f %f %f %f %f %d\n", id,x,y,sx,sy,behav);
|
471
|
57 }
|
|
58
|
|
59 void
|
|
60 test2(int id, int x,float y,float sx,float sy,int behav)
|
|
61 {
|
491
|
62 printf("#0061:%d %d %f %f %f %d\n", id,x,y,sx,sy,behav);
|
471
|
63 }
|
|
64
|
|
65 void
|
|
66 test3(int id, float x,float y,float sx,float sy,int behav)
|
|
67 {
|
491
|
68 printf("#0067:%d %f %f %f %f %d\n", id,x,y,sx,sy,behav);
|
471
|
69 }
|
|
70
|
|
71 void
|
|
72 test4(int id, float x,int y,float sx,float sy,int behav)
|
|
73 {
|
491
|
74 printf("#0073:%d %f %d %f %f %d\n", id,x,y,sx,sy,behav);
|
471
|
75 }
|
|
76
|
|
77 void
|
|
78 test5(float id, int x,float y,int sx,float sy,int behav)
|
|
79 {
|
491
|
80 printf("#0079:%f %d %f %d %f %d\n", id,x,y,sx,sy,behav);
|
471
|
81 }
|
|
82
|
|
83
|
|
84
|
79
|
85 int
|
|
86 main(int ac,char *av[]) {
|
82
|
87 double g;
|
|
88 int i;
|
85
|
89 unsigned u;
|
108
|
90 double d00 = ac?0.5:3;
|
|
91
|
491
|
92 printf("#0091:%g\n",d00);
|
82
|
93
|
471
|
94 test1(1,2,3,10,11,4);
|
|
95 test2(1,2,3,10,11,4);
|
|
96 test3(1,2,3,10,11,4);
|
|
97 test4(1,2,3,10,11,4);
|
|
98 test5(1,2,3,10,11,4);
|
479
|
99 test7();
|
471
|
100
|
82
|
101 g = 1.0;
|
|
102 g = -g;
|
491
|
103 printf("#0102:%d\ncond0 ",1);
|
|
104 if(f==f*1.0) printf("#0103:t ");
|
|
105 printf("#0104:%d\ncond1 ",f==f*1.0);
|
|
106 if(d==f*1.0) printf("#0105:t ");
|
|
107 printf("#0106:%d\ncond2 ",d==f*1.0);
|
|
108 if(f==f1) printf("#0107:t ");
|
|
109 printf("#0108:%d\ncond3 ",f==f1);
|
|
110 if(d==d1) printf("#0109:t ");
|
|
111 printf("#0110:%d\ncond4 ",d==d2);
|
|
112 if(d==d2) printf("#0111:t ");
|
|
113 printf("#0112:%d\ncond5 ",(d==d2));
|
|
114 if(d>d1) printf("#0113:t ");
|
|
115 printf("#0114:%d\ncond6 ",d>d1);
|
|
116 if(d>d2) printf("#0115:t ");
|
|
117 printf("#0116:%d\ncond7 ",d>d2);
|
|
118 if(d>=d1) printf("#0117:t ");
|
|
119 printf("#0118:%d\ncond8 ",d>=d1);
|
|
120 if(d>=d2) printf("#0119:t ");
|
|
121 printf("#0120:%d\ncond9 ",d>=d2);
|
|
122 if(d!=d1) printf("#0121:t ");
|
|
123 printf("#0122:%d\ncond10 ",d!=d1);
|
|
124 if(d!=d2) printf("#0123:5 ");
|
|
125 printf("#0124:%d\ncond11 ",d!=d2);
|
|
126 if(d<d1) printf("#0125:t ");
|
|
127 printf("#0126:%d\ncond12 ",d<d1);
|
|
128 if(d<d2) printf("#0127:t ");
|
|
129 printf("#0128:%d\ncond13 ",d<d2);
|
|
130 if(d<=d1) printf("#0129:t ");
|
|
131 printf("#0130:%d\ncond14 ",d<=d1);
|
|
132 if(d<=d2) printf("#0131:t ");
|
|
133 printf("#0132:%d\ncond15 ",d<=d2);
|
85
|
134 d = 123.4234; f=-234.333;
|
82
|
135 i = d;
|
|
136 d = i;
|
|
137 i = f;
|
|
138 f = i;
|
491
|
139 printf("#0138:\ni=%d d=%g f=%f",i,d,f);
|
94
|
140 f = g = d = d1 = d2 = f;
|
491
|
141 printf("#0140: i=%d d=%g f=%f g=%g\n",i,d,f,g);
|
82
|
142
|
86
|
143 d = 4204967294.4234; f=4204967294.4234;
|
85
|
144 u = d;
|
491
|
145 printf("#0144:1: u=%u d=%g f=%f\n",u,d,f);
|
85
|
146 d = u;
|
491
|
147 printf("#0146:2: u=%u d=%g f=%f\n",u,d,f);
|
85
|
148 u = f;
|
491
|
149 printf("#0148:3: u=%u d=%g f=%f\n",u,d,f);
|
85
|
150 f = u;
|
491
|
151 printf("#0150:4: u=%u d=%g f=%f\n",u,d,f);
|
85
|
152
|
82
|
153 print(1.0);
|
|
154 print(0.1234);
|
|
155 print(1.234e10);
|
|
156 print(1.234e-10);
|
|
157
|
472
|
158 test8();
|
491
|
159 printf("#0158:nested call: %g\n",test9(test9(test9(test9(-0.333,3),5),6),7));
|
79
|
160 return 0;
|
|
161 }
|
|
162
|
82
|
163 void
|
|
164 print(double d)
|
|
165 {
|
|
166 float f;
|
|
167 int *dd;
|
|
168
|
|
169 f = d;
|
|
170
|
|
171 dd = (int*) &d;
|
491
|
172 printf("#0171:d %g ",d);
|
|
173 printf("#0172:dx %08x %08x\n",*(dd),*(dd+1));
|
82
|
174
|
|
175 dd = (int*) &f;
|
491
|
176 printf("#0175:f %g ",f);
|
|
177 printf("#0176:dx %08x \n",*(dd));
|
82
|
178 }
|
|
179
|
81
|
180 double
|
|
181 testd(double i,double j)
|
|
182 {
|
87
|
183 return j+1.1+.0e3+12.3e-12;
|
81
|
184 }
|
|
185
|
|
186 float
|
|
187 testf(float i,float j)
|
|
188 {
|
87
|
189 return j+1;
|
81
|
190 }
|
|
191
|
79
|
192 void
|
472
|
193 test8()
|
79
|
194 {
|
|
195 float f;
|
|
196 float f1;
|
|
197 double g;
|
|
198 double g1;
|
85
|
199 float *pf;
|
|
200 float *pf1;
|
|
201 double *pg;
|
|
202 double *pg1;
|
|
203 int n = 1;
|
79
|
204
|
491
|
205 printf("#0204:simple double ");
|
79
|
206 f = 1.3;
|
|
207
|
|
208 g = 1.0;
|
|
209 g = g+g;
|
491
|
210 printf("#0209:%d:%g\t",n++,g);
|
79
|
211 g1 = g*g;
|
491
|
212 printf("#0211:%d:%g\t",n++,g1);
|
79
|
213 g = g/g1;
|
491
|
214 printf("#0213:%d:%g\t",n++,g);
|
79
|
215 g = g-g1;
|
491
|
216 printf("#0215:%d:%g\t",n++,g);
|
79
|
217 g = sin(g1);
|
491
|
218 printf("#0217:%d:%g\t",n++,g);
|
81
|
219 g = testd(g,g1);
|
491
|
220 printf("#0219:%d:%g\t",n++,g);
|
|
221 printf("#0220:\n");
|
79
|
222
|
491
|
223 printf("#0222:simple float ");
|
79
|
224 f = f+f;
|
491
|
225 printf("#0224:%d:%g\t",n++,f);
|
79
|
226 f1 = f*f;
|
491
|
227 printf("#0226:%d:%g\t",n++,f1);
|
79
|
228 f = f/f1;
|
491
|
229 printf("#0228:%d:%g\t",n++,f);
|
79
|
230 f = f-f1;
|
491
|
231 printf("#0230:%d:%g\t",n++,f);
|
79
|
232 f = sin(f1);
|
491
|
233 printf("#0232:%d:%g\t",n++,f);
|
|
234 printf("#0233:\n");
|
85
|
235
|
491
|
236 printf("#0235:post/pre increment ");
|
86
|
237 g1 = g;
|
491
|
238 printf("#0237:%d:%g\t",n++,g1++ - ++g);
|
85
|
239
|
86
|
240 f1 = f;
|
491
|
241 printf("#0240:%d:%g\t",n++,f1++ - ++f);
|
87
|
242
|
|
243 g1 = g;
|
491
|
244 printf("#0243:%d:%g\t",n++,g1-- - --g);
|
87
|
245
|
|
246 f1 = f;
|
491
|
247 printf("#0246:%d:%g\t",n++,f1-- - --f);
|
87
|
248
|
491
|
249 printf("#0248:\n");
|
|
250 printf("#0249:simple calc ");
|
87
|
251
|
|
252 f=0.13; g=-0.56; f1=-0.13; g1=0.56;
|
79
|
253
|
|
254 g = f+f;
|
491
|
255 printf("#0254:%d:%g\t",n++,g);
|
79
|
256 f = g*g;
|
491
|
257 printf("#0256:%d:%g\t",n++,f);
|
79
|
258 g = g*g+f*f-g1*g1;
|
491
|
259 printf("#0258:%d:%g\t",n++,g);
|
|
260 printf("#0259:\n");
|
79
|
261
|
491
|
262 printf("#0261:float argument ");
|
87
|
263 f = testf(f,f1);
|
491
|
264 printf("#0263:%d:%g\t",n++,f);
|
87
|
265
|
491
|
266 printf("#0265:\nindirect ");
|
85
|
267 n=1;
|
|
268 f = 1.3; pf=&f; pf1=&f1;
|
|
269
|
|
270 g = 1.0; pg=&g; pg1=&g1;
|
|
271 *pg = *pg+ *pg;
|
491
|
272 printf("#0271:%d:%g\t",n++,*pg);
|
85
|
273 *pg1 = *pg**pg;
|
491
|
274 printf("#0273:%d:%g\t",n++,*pg1);
|
85
|
275 *pg = *pg/ *pg1;
|
491
|
276 printf("#0275:%d:%g\t",n++,*pg);
|
85
|
277 *pg = *pg-*pg1;
|
491
|
278 printf("#0277:%d:%g\t",n++,*pg);
|
85
|
279 *pg = sin(*pg1);
|
491
|
280 printf("#0279:%d:%g\t",n++,*pg);
|
85
|
281 *pg = testd(*pg,*pg1);
|
491
|
282 printf("#0281:%d:%g\t",n++,*pg);
|
|
283 printf("#0282:\n");
|
85
|
284
|
|
285 *pf = *pf+*pf;
|
491
|
286 printf("#0285:%d:%g\t",n++,*pf);
|
85
|
287 *pf1 = *pf**pf;
|
491
|
288 printf("#0287:%d:%g\t",n++,*pf1);
|
85
|
289 *pf = *pf/ *pf1;
|
491
|
290 printf("#0289:%d:%g\t",n++,*pf);
|
85
|
291 *pf = *pf-*pf1;
|
491
|
292 printf("#0291:%d:%g\t",n++,*pf);
|
85
|
293 *pf = sin(*pf1);
|
491
|
294 printf("#0293:%d:%g\t",n++,*pf);
|
|
295 printf("#0294:\n");
|
85
|
296
|
491
|
297 printf("#0296:indirect post/pre ");
|
86
|
298 *pg1 = *pg;
|
491
|
299 printf("#0298:%d:%g\t",n++,(*pg1)++ - ++(*pg));
|
85
|
300
|
86
|
301 *pf1 = *pf;
|
491
|
302 printf("#0301:%d:%g\t",n++,(*pf1)++ - ++(*pf));
|
87
|
303
|
|
304 *pg1 = *pg;
|
491
|
305 printf("#0304:%d:%g\t",n++, (*pg1)-- - --(*pg));
|
86
|
306
|
87
|
307 *pf1 = *pf;
|
491
|
308 printf("#0307:%d:%g\t",n++, (*pf1)-- - --(*pf));
|
|
309 printf("#0308:\n");
|
87
|
310
|
|
311 *pf=0.13; *pg=-0.56; *pf1=-0.13; *pg1=0.56;
|
85
|
312
|
|
313 *pg = *pf+*pf;
|
491
|
314 printf("#0313:%d:%g\t",n++,*pg);
|
85
|
315 *pf = *pg**pg;
|
491
|
316 printf("#0315:%d:%g\t",n++,*pf);
|
85
|
317 *pg = *pg**pg+*pf**pf-*pg1**pg1;
|
491
|
318 printf("#0317:%d:%g\t",n++,*pg);
|
|
319 printf("#0318:\n");
|
85
|
320
|
491
|
321 printf("#0320:float argument ");
|
87
|
322
|
|
323 *pf = testf(*pf,*pf1);
|
491
|
324 printf("#0323:%d:%g\t",n++,*pf);
|
87
|
325
|
|
326
|
491
|
327 printf("#0326:\nassop ");
|
85
|
328 n=1;
|
|
329 f = 1.3;
|
|
330 g = 1.0;
|
|
331
|
|
332 g *= 2*g;
|
491
|
333 printf("#0332:%d:%g\t",n++,g);
|
85
|
334 g /= 2*g;
|
491
|
335 printf("#0334:%d:%g\t",n++,g);
|
85
|
336 g -= 2*g;
|
491
|
337 printf("#0336:%d:%g\t",n++,g);
|
85
|
338 g += 2*g;
|
491
|
339 printf("#0338:%d:%g\t",n++,g);
|
85
|
340
|
|
341 f *= 2*g;
|
491
|
342 printf("#0341:%d:%g\t",n++,f);
|
85
|
343 f /= 2*g;
|
491
|
344 printf("#0343:%d:%g\t",n++,f);
|
85
|
345 f -= 2*g;
|
491
|
346 printf("#0345:%d:%g\t",n++,f);
|
85
|
347 f += 2*g;
|
491
|
348 printf("#0347:%d:%g\t",n++,f);
|
|
349 printf("#0348:\n");
|
85
|
350
|
|
351 n=1;
|
|
352 f = 1.3;
|
|
353 g = 1.0;
|
|
354
|
491
|
355 printf("#0354:indirect assop ");
|
85
|
356 *pg *= 2**pg;
|
491
|
357 printf("#0356:%d:%g\t",n++,*pg);
|
85
|
358 *pg /= 2**pg;
|
491
|
359 printf("#0358:%d:%g\t",n++,*pg);
|
85
|
360 *pg -= 2**pg;
|
491
|
361 printf("#0360:%d:%g\t",n++,*pg);
|
85
|
362 *pg += 2**pg;
|
491
|
363 printf("#0362:%d:%g\t",n++,*pg);
|
85
|
364
|
|
365 *pf *= 2**pg;
|
491
|
366 printf("#0365:%d:%g\t",n++,*pf);
|
85
|
367 *pf /= 2**pg;
|
491
|
368 printf("#0367:%d:%g\t",n++,*pf);
|
85
|
369 *pf -= 2**pg;
|
491
|
370 printf("#0369:%d:%g\t",n++,*pf);
|
85
|
371 *pf += 2**pg;
|
491
|
372 printf("#0371:%d:%g\t",n++,*pf);
|
|
373 printf("#0372:\n");
|
85
|
374
|
|
375
|
79
|
376 return;
|
|
377 }
|
94
|
378
|
|
379 double
|
473
|
380 test9(double f,int i)
|
94
|
381 {
|
|
382 double g,h;
|
|
383
|
|
384 if (i<=0) return f;
|
112
|
385 #if 1
|
491
|
386 printf("#0385:rec: %d %g\n",i,f);
|
112
|
387 #endif
|
94
|
388 g = f*2;
|
|
389 h = f-0.5;
|
473
|
390 return h/3-(3.0-(g+3)*test9(f*0.5,i-1)/(h-1));
|
94
|
391 }
|
471
|
392
|
479
|
393 struct huga0 {
|
|
394 char c;
|
|
395 short s;
|
|
396 int i;
|
|
397 long l;
|
|
398 float f;
|
|
399 };
|
|
400 struct huga {
|
|
401 char c;
|
|
402 short s;
|
|
403 int i;
|
|
404 long l;
|
|
405 float f;
|
|
406 struct huga0 hh;
|
|
407 };
|
471
|
408
|
479
|
409
|
|
410 struct enemy{
|
|
411 int charno; // image number
|
|
412 float x; // x location
|
|
413 float y; // y location
|
|
414 int ap; // armor point
|
|
415 };
|
|
416
|
|
417 void
|
|
418 print_param(struct enemy *e)
|
|
419 {
|
491
|
420 printf("#0419:charno:%d x,y:%f,%f hp:%d\n",
|
479
|
421 e->charno,e->x,e->y,e->ap);
|
|
422 }
|
|
423
|
|
424
|
|
425 int test7()
|
|
426 {
|
|
427 struct huga h;
|
|
428 struct enemy e;
|
|
429
|
|
430 h.c = 10;
|
|
431 h.s = 20;
|
|
432 h.i = 30;
|
|
433 h.l = 40;
|
|
434 h.f = 50;
|
|
435 h.hh.c = 10;
|
|
436 h.hh.s = 20;
|
|
437 h.hh.i = 30;
|
|
438 h.hh.l = 40;
|
|
439 h.hh.f = 50;
|
|
440
|
|
441
|
|
442 e.charno=5; e.x=50.0; e.y=30.0; e.ap=100;
|
|
443 print_param(&e);
|
|
444 return (0);
|
|
445 }
|
|
446
|