79
|
1 #include "stdio.h"
|
|
2
|
|
3 void test2(double);
|
|
4 void test1();
|
82
|
5 void print(double d);
|
79
|
6
|
81
|
7 extern double sin(double);
|
84
|
8 // extern float fsin(float);
|
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;
|
82
|
15
|
79
|
16 int
|
|
17 main(int ac,char *av[]) {
|
82
|
18 double g;
|
|
19 int i;
|
85
|
20 unsigned u;
|
82
|
21
|
|
22 g = 1.0;
|
|
23 g = -g;
|
84
|
24 printf("%g\ncond ",g);
|
|
25 if(f==f*1.0) printf("1 ");
|
|
26 if(d==f*1.0) printf("2 ");
|
|
27 if(f==f1) printf("3 ");
|
|
28 if(d==d1) printf("4 ");
|
|
29 if(d==d2) printf("-4 ");
|
|
30 if(d>d1) printf("5 ");
|
|
31 if(d>d2) printf("-5 ");
|
|
32 if(d>=d1) printf("6 ");
|
|
33 if(d>=d2) printf("-6 ");
|
|
34 if(d!=d1) printf("7 ");
|
|
35 if(d!=d2) printf("-7 ");
|
|
36 if(d<d1) printf("8 ");
|
|
37 if(d<d2) printf("-8 ");
|
|
38 if(d<=d1) printf("9 ");
|
|
39 if(d<=d2) printf("-9 ");
|
85
|
40 d = 123.4234; f=-234.333;
|
82
|
41 i = d;
|
|
42 d = i;
|
|
43 i = f;
|
|
44 f = i;
|
84
|
45 printf("\n%d %g %f",i,d,f);
|
82
|
46 f = g = d = g = d = f;
|
84
|
47 printf(" %d %g %f %g\n",i,d,f,g);
|
82
|
48
|
86
|
49 d = 4204967294.4234; f=4204967294.4234;
|
85
|
50 u = d;
|
|
51 d = u;
|
|
52 u = f;
|
|
53 f = u;
|
|
54 printf("%u %g %f\n",u,d,f);
|
|
55
|
82
|
56 print(1.0);
|
|
57 print(0.1234);
|
|
58 print(1.234e10);
|
|
59 print(1.234e-10);
|
|
60
|
79
|
61 test1();
|
|
62 return 0;
|
|
63 }
|
|
64
|
82
|
65 void
|
|
66 print(double d)
|
|
67 {
|
|
68 float f;
|
|
69 int *dd;
|
|
70
|
|
71 f = d;
|
|
72
|
|
73 dd = (int*) &d;
|
84
|
74 printf("d %g ",d);
|
82
|
75 printf("dx %08x %08x\n",*(dd),*(dd+1));
|
|
76
|
|
77 dd = (int*) &f;
|
84
|
78 printf("f %g ",f);
|
82
|
79 printf("dx %08x \n",*(dd));
|
|
80 }
|
|
81
|
81
|
82 double
|
|
83 testd(double i,double j)
|
|
84 {
|
|
85 return i+1.1+.0e3+12.3e-12;
|
|
86 }
|
|
87
|
|
88 float
|
|
89 testf(float i,float j)
|
|
90 {
|
|
91 return i+1;
|
|
92 }
|
|
93
|
79
|
94 void
|
|
95 test1()
|
|
96 {
|
|
97 float f;
|
|
98 float f1;
|
|
99 double g;
|
|
100 double g1;
|
85
|
101 float *pf;
|
|
102 float *pf1;
|
|
103 double *pg;
|
|
104 double *pg1;
|
|
105 int n = 1;
|
79
|
106
|
|
107 f = 1.3;
|
|
108
|
|
109 g = 1.0;
|
|
110 g = g+g;
|
85
|
111 printf("%d:%g\t",n++,g);
|
79
|
112 g1 = g*g;
|
85
|
113 printf("%d:%g\t",n++,g1);
|
79
|
114 g = g/g1;
|
85
|
115 printf("%d:%g\t",n++,g);
|
79
|
116 g = g-g1;
|
85
|
117 printf("%d:%g\t",n++,g);
|
79
|
118 g = sin(g1);
|
85
|
119 printf("%d:%g\t",n++,g);
|
81
|
120 g = testd(g,g1);
|
85
|
121 printf("%d:%g\t",n++,g);
|
|
122 printf("\n");
|
79
|
123
|
|
124 f = f+f;
|
85
|
125 printf("%d:%g\t",n++,f);
|
79
|
126 f1 = f*f;
|
85
|
127 printf("%d:%g\t",n++,f1);
|
79
|
128 f = f/f1;
|
85
|
129 printf("%d:%g\t",n++,f);
|
79
|
130 f = f-f1;
|
85
|
131 printf("%d:%g\t",n++,f);
|
79
|
132 f = sin(f1);
|
85
|
133 printf("%d:%g\t",n++,f);
|
|
134 printf("\n");
|
|
135
|
86
|
136 g1 = g;
|
|
137 g1 = g1++ - ++g;
|
|
138 printf("%d:%g\t",n++,g1);
|
85
|
139
|
86
|
140 f1 = f;
|
|
141 f1 = f1++ - ++f;
|
|
142 printf("%d:%g\t",n++,f1);
|
79
|
143
|
|
144 g = f+f;
|
85
|
145 printf("%d:%g\t",n++,g);
|
79
|
146 f = g*g;
|
85
|
147 printf("%d:%g\t",n++,f);
|
81
|
148 f = testf(f,f1);
|
85
|
149 printf("%d:%g\t",n++,f);
|
79
|
150
|
|
151 g = g*g+f*f-g1*g1;
|
85
|
152 printf("%d:%g\t",n++,g);
|
|
153 printf("\n");
|
79
|
154
|
85
|
155 n=1;
|
|
156 f = 1.3; pf=&f; pf1=&f1;
|
|
157
|
|
158 g = 1.0; pg=&g; pg1=&g1;
|
|
159 *pg = *pg+ *pg;
|
|
160 printf("%d:%g\t",n++,*pg);
|
|
161 *pg1 = *pg**pg;
|
|
162 printf("%d:%g\t",n++,*pg1);
|
|
163 *pg = *pg/ *pg1;
|
|
164 printf("%d:%g\t",n++,*pg);
|
|
165 *pg = *pg-*pg1;
|
|
166 printf("%d:%g\t",n++,*pg);
|
|
167 *pg = sin(*pg1);
|
|
168 printf("%d:%g\t",n++,*pg);
|
|
169 *pg = testd(*pg,*pg1);
|
|
170 printf("%d:%g\t",n++,*pg);
|
|
171 printf("\n");
|
|
172
|
|
173 *pf = *pf+*pf;
|
|
174 printf("%d:%g\t",n++,*pf);
|
|
175 *pf1 = *pf**pf;
|
|
176 printf("%d:%g\t",n++,*pf1);
|
|
177 *pf = *pf/ *pf1;
|
|
178 printf("%d:%g\t",n++,*pf);
|
|
179 *pf = *pf-*pf1;
|
|
180 printf("%d:%g\t",n++,*pf);
|
|
181 *pf = sin(*pf1);
|
|
182 printf("%d:%g\t",n++,*pf);
|
|
183 printf("\n");
|
|
184
|
86
|
185 *pg1 = *pg;
|
|
186 *pg1 = (*pg1)++ - ++(*pg);
|
|
187 printf("%d:%g\t",n++,*pg1);
|
85
|
188
|
86
|
189 *pf1 = *pf;
|
|
190 *pf1 = (*pf1)++ - ++(*pf);
|
|
191 printf("%d:%g\t",n++,*pf1);
|
|
192
|
85
|
193
|
|
194 *pg = *pf+*pf;
|
|
195 printf("%d:%g\t",n++,*pg);
|
|
196 *pf = *pg**pg;
|
|
197 printf("%d:%g\t",n++,*pf);
|
|
198 *pf = testf(*pf,*pf1);
|
|
199 printf("%d:%g\t",n++,*pf);
|
|
200
|
|
201 *pg = *pg**pg+*pf**pf-*pg1**pg1;
|
|
202 printf("%d:%g\t",n++,*pg);
|
|
203 printf("\n");
|
|
204
|
|
205 n=1;
|
|
206 f = 1.3;
|
|
207 g = 1.0;
|
|
208
|
|
209 g *= 2*g;
|
|
210 printf("%d:%g\t",n++,g);
|
|
211 g /= 2*g;
|
|
212 printf("%d:%g\t",n++,g);
|
|
213 g -= 2*g;
|
|
214 printf("%d:%g\t",n++,g);
|
|
215 g += 2*g;
|
|
216 printf("%d:%g\t",n++,g);
|
|
217
|
|
218 f *= 2*g;
|
|
219 printf("%d:%g\t",n++,f);
|
|
220 f /= 2*g;
|
|
221 printf("%d:%g\t",n++,f);
|
|
222 f -= 2*g;
|
|
223 printf("%d:%g\t",n++,f);
|
|
224 f += 2*g;
|
|
225 printf("%d:%g\t",n++,f);
|
|
226 printf("\n");
|
|
227
|
|
228 n=1;
|
|
229 f = 1.3;
|
|
230 g = 1.0;
|
|
231
|
|
232 *pg *= 2**pg;
|
|
233 printf("%d:%g\t",n++,*pg);
|
|
234 *pg /= 2**pg;
|
|
235 printf("%d:%g\t",n++,*pg);
|
|
236 *pg -= 2**pg;
|
|
237 printf("%d:%g\t",n++,*pg);
|
|
238 *pg += 2**pg;
|
|
239 printf("%d:%g\t",n++,*pg);
|
|
240
|
|
241 *pf *= 2**pg;
|
|
242 printf("%d:%g\t",n++,*pf);
|
|
243 *pf /= 2**pg;
|
|
244 printf("%d:%g\t",n++,*pf);
|
|
245 *pf -= 2**pg;
|
|
246 printf("%d:%g\t",n++,*pf);
|
|
247 *pf += 2**pg;
|
|
248 printf("%d:%g\t",n++,*pf);
|
|
249 printf("\n");
|
|
250
|
|
251
|
79
|
252 return;
|
|
253 }
|