annotate test/float.c @ 94:1ad7045741a7 dbinop

float dbinop fix
author kono
date Wed, 12 Mar 2003 15:28:44 +0900
parents 9b1aeb62e0b9
children 7d8de41390d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
1 #include "stdio.h"
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
2
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
3 void test1();
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
4 void print(double d);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
5
81
f94ca1168520 float first try...
kono
parents: 79
diff changeset
6 extern double sin(double);
84
1a723130a2c7 condtional
kono
parents: 82
diff changeset
7 // extern float fsin(float);
94
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
8 double test2(double f,int i);
81
f94ca1168520 float first try...
kono
parents: 79
diff changeset
9
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
10 float f = 0.3;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
11 double d = 0.3;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
12 float f1 = 0.3;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
13 double d1 = 0.3;
84
1a723130a2c7 condtional
kono
parents: 82
diff changeset
14 double d2 = -0.2;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
15
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
16 int
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
17 d2i(double d) {
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
18 return (int)d;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
19 }
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
20
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
21 double
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
22 i2d(int u) {
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
23 return (double)u;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
24 }
90
07e3113c3c13 *** empty log message ***
kono
parents: 87
diff changeset
25
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
26 unsigned u;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
27 unsigned
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
28 d2u(double d) {
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
29 return (unsigned)d;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
30 }
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
31
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
32 double
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
33 u2d(unsigned u) {
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
34 return (double)u;
90
07e3113c3c13 *** empty log message ***
kono
parents: 87
diff changeset
35 }
07e3113c3c13 *** empty log message ***
kono
parents: 87
diff changeset
36
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
37 int
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
38 main(int ac,char *av[]) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
39 double g;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
40 int i;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
41 unsigned u;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
42
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
43 g = 1.0;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
44 g = -g;
84
1a723130a2c7 condtional
kono
parents: 82
diff changeset
45 printf("%g\ncond ",g);
1a723130a2c7 condtional
kono
parents: 82
diff changeset
46 if(f==f*1.0) printf("1 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
47 if(d==f*1.0) printf("2 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
48 if(f==f1) printf("3 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
49 if(d==d1) printf("4 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
50 if(d==d2) printf("-4 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
51 if(d>d1) printf("5 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
52 if(d>d2) printf("-5 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
53 if(d>=d1) printf("6 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
54 if(d>=d2) printf("-6 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
55 if(d!=d1) printf("7 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
56 if(d!=d2) printf("-7 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
57 if(d<d1) printf("8 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
58 if(d<d2) printf("-8 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
59 if(d<=d1) printf("9 ");
1a723130a2c7 condtional
kono
parents: 82
diff changeset
60 if(d<=d2) printf("-9 ");
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
61 d = 123.4234; f=-234.333;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
62 i = d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
63 d = i;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
64 i = f;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
65 f = i;
84
1a723130a2c7 condtional
kono
parents: 82
diff changeset
66 printf("\n%d %g %f",i,d,f);
94
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
67 f = g = d = d1 = d2 = f;
84
1a723130a2c7 condtional
kono
parents: 82
diff changeset
68 printf(" %d %g %f %g\n",i,d,f,g);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
69
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
70 d = 4204967294.4234; f=4204967294.4234;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
71 u = d;
3789aef7331d minor fix
kono
parents: 84
diff changeset
72 d = u;
3789aef7331d minor fix
kono
parents: 84
diff changeset
73 u = f;
3789aef7331d minor fix
kono
parents: 84
diff changeset
74 f = u;
3789aef7331d minor fix
kono
parents: 84
diff changeset
75 printf("%u %g %f\n",u,d,f);
3789aef7331d minor fix
kono
parents: 84
diff changeset
76
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
77 print(1.0);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
78 print(0.1234);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
79 print(1.234e10);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
80 print(1.234e-10);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
81
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
82 test1();
94
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
83 printf("nested call: %g\n",test2(test2(test2(test2(-0.333,3),5),6),7));
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
84 return 0;
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
85 }
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
86
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
87 void
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
88 print(double d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
89 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
90 float f;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
91 int *dd;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
92
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
93 f = d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
94
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
95 dd = (int*) &d;
84
1a723130a2c7 condtional
kono
parents: 82
diff changeset
96 printf("d %g ",d);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
97 printf("dx %08x %08x\n",*(dd),*(dd+1));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
98
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
99 dd = (int*) &f;
84
1a723130a2c7 condtional
kono
parents: 82
diff changeset
100 printf("f %g ",f);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
101 printf("dx %08x \n",*(dd));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
102 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
103
81
f94ca1168520 float first try...
kono
parents: 79
diff changeset
104 double
f94ca1168520 float first try...
kono
parents: 79
diff changeset
105 testd(double i,double j)
f94ca1168520 float first try...
kono
parents: 79
diff changeset
106 {
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
107 return j+1.1+.0e3+12.3e-12;
81
f94ca1168520 float first try...
kono
parents: 79
diff changeset
108 }
f94ca1168520 float first try...
kono
parents: 79
diff changeset
109
f94ca1168520 float first try...
kono
parents: 79
diff changeset
110 float
f94ca1168520 float first try...
kono
parents: 79
diff changeset
111 testf(float i,float j)
f94ca1168520 float first try...
kono
parents: 79
diff changeset
112 {
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
113 return j+1;
81
f94ca1168520 float first try...
kono
parents: 79
diff changeset
114 }
f94ca1168520 float first try...
kono
parents: 79
diff changeset
115
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
116 void
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
117 test1()
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
118 {
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
119 float f;
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
120 float f1;
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
121 double g;
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
122 double g1;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
123 float *pf;
3789aef7331d minor fix
kono
parents: 84
diff changeset
124 float *pf1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
125 double *pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
126 double *pg1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
127 int n = 1;
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
128
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
129 printf("simple double ");
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
130 f = 1.3;
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
131
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
132 g = 1.0;
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
133 g = g+g;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
134 printf("%d:%g\t",n++,g);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
135 g1 = g*g;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
136 printf("%d:%g\t",n++,g1);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
137 g = g/g1;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
138 printf("%d:%g\t",n++,g);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
139 g = g-g1;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
140 printf("%d:%g\t",n++,g);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
141 g = sin(g1);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
142 printf("%d:%g\t",n++,g);
81
f94ca1168520 float first try...
kono
parents: 79
diff changeset
143 g = testd(g,g1);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
144 printf("%d:%g\t",n++,g);
3789aef7331d minor fix
kono
parents: 84
diff changeset
145 printf("\n");
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
146
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
147 printf("simple float ");
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
148 f = f+f;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
149 printf("%d:%g\t",n++,f);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
150 f1 = f*f;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
151 printf("%d:%g\t",n++,f1);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
152 f = f/f1;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
153 printf("%d:%g\t",n++,f);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
154 f = f-f1;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
155 printf("%d:%g\t",n++,f);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
156 f = sin(f1);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
157 printf("%d:%g\t",n++,f);
3789aef7331d minor fix
kono
parents: 84
diff changeset
158 printf("\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
159
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
160 printf("post/pre increment ");
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
161 g1 = g;
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
162 printf("%d:%g\t",n++,g1++ - ++g);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
163
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
164 f1 = f;
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
165 printf("%d:%g\t",n++,f1++ - ++f);
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
166
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
167 g1 = g;
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
168 printf("%d:%g\t",n++,g1-- - --g);
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
169
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
170 f1 = f;
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
171 printf("%d:%g\t",n++,f1-- - --f);
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
172
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
173 printf("\n");
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
174 printf("simple calc ");
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
175
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
176 f=0.13; g=-0.56; f1=-0.13; g1=0.56;
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
177
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
178 g = f+f;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
179 printf("%d:%g\t",n++,g);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
180 f = g*g;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
181 printf("%d:%g\t",n++,f);
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
182 g = g*g+f*f-g1*g1;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
183 printf("%d:%g\t",n++,g);
3789aef7331d minor fix
kono
parents: 84
diff changeset
184 printf("\n");
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
185
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
186 printf("float argument ");
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
187 f = testf(f,f1);
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
188 printf("%d:%g\t",n++,f);
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
189
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
190 printf("\nindirect ");
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
191 n=1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
192 f = 1.3; pf=&f; pf1=&f1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
193
3789aef7331d minor fix
kono
parents: 84
diff changeset
194 g = 1.0; pg=&g; pg1=&g1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
195 *pg = *pg+ *pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
196 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
197 *pg1 = *pg**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
198 printf("%d:%g\t",n++,*pg1);
3789aef7331d minor fix
kono
parents: 84
diff changeset
199 *pg = *pg/ *pg1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
200 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
201 *pg = *pg-*pg1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
202 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
203 *pg = sin(*pg1);
3789aef7331d minor fix
kono
parents: 84
diff changeset
204 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
205 *pg = testd(*pg,*pg1);
3789aef7331d minor fix
kono
parents: 84
diff changeset
206 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
207 printf("\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
208
3789aef7331d minor fix
kono
parents: 84
diff changeset
209 *pf = *pf+*pf;
3789aef7331d minor fix
kono
parents: 84
diff changeset
210 printf("%d:%g\t",n++,*pf);
3789aef7331d minor fix
kono
parents: 84
diff changeset
211 *pf1 = *pf**pf;
3789aef7331d minor fix
kono
parents: 84
diff changeset
212 printf("%d:%g\t",n++,*pf1);
3789aef7331d minor fix
kono
parents: 84
diff changeset
213 *pf = *pf/ *pf1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
214 printf("%d:%g\t",n++,*pf);
3789aef7331d minor fix
kono
parents: 84
diff changeset
215 *pf = *pf-*pf1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
216 printf("%d:%g\t",n++,*pf);
3789aef7331d minor fix
kono
parents: 84
diff changeset
217 *pf = sin(*pf1);
3789aef7331d minor fix
kono
parents: 84
diff changeset
218 printf("%d:%g\t",n++,*pf);
3789aef7331d minor fix
kono
parents: 84
diff changeset
219 printf("\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
220
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
221 printf("indirect post/pre ");
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
222 *pg1 = *pg;
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
223 printf("%d:%g\t",n++,(*pg1)++ - ++(*pg));
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
224
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
225 *pf1 = *pf;
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
226 printf("%d:%g\t",n++,(*pf1)++ - ++(*pf));
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
227
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
228 *pg1 = *pg;
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
229 printf("%d:%g\t",n++, (*pg1)-- - --(*pg));
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
230
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
231 *pf1 = *pf;
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
232 printf("%d:%g\t",n++, (*pf1)-- - --(*pf));
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
233 printf("\n");
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
234
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
235 *pf=0.13; *pg=-0.56; *pf1=-0.13; *pg1=0.56;
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
236
3789aef7331d minor fix
kono
parents: 84
diff changeset
237 *pg = *pf+*pf;
3789aef7331d minor fix
kono
parents: 84
diff changeset
238 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
239 *pf = *pg**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
240 printf("%d:%g\t",n++,*pf);
3789aef7331d minor fix
kono
parents: 84
diff changeset
241 *pg = *pg**pg+*pf**pf-*pg1**pg1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
242 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
243 printf("\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
244
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
245 printf("float argument ");
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
246
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
247 *pf = testf(*pf,*pf1);
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
248 printf("%d:%g\t",n++,*pf);
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
249
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
250
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
251 printf("\nassop ");
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
252 n=1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
253 f = 1.3;
3789aef7331d minor fix
kono
parents: 84
diff changeset
254 g = 1.0;
3789aef7331d minor fix
kono
parents: 84
diff changeset
255
3789aef7331d minor fix
kono
parents: 84
diff changeset
256 g *= 2*g;
3789aef7331d minor fix
kono
parents: 84
diff changeset
257 printf("%d:%g\t",n++,g);
3789aef7331d minor fix
kono
parents: 84
diff changeset
258 g /= 2*g;
3789aef7331d minor fix
kono
parents: 84
diff changeset
259 printf("%d:%g\t",n++,g);
3789aef7331d minor fix
kono
parents: 84
diff changeset
260 g -= 2*g;
3789aef7331d minor fix
kono
parents: 84
diff changeset
261 printf("%d:%g\t",n++,g);
3789aef7331d minor fix
kono
parents: 84
diff changeset
262 g += 2*g;
3789aef7331d minor fix
kono
parents: 84
diff changeset
263 printf("%d:%g\t",n++,g);
3789aef7331d minor fix
kono
parents: 84
diff changeset
264
3789aef7331d minor fix
kono
parents: 84
diff changeset
265 f *= 2*g;
3789aef7331d minor fix
kono
parents: 84
diff changeset
266 printf("%d:%g\t",n++,f);
3789aef7331d minor fix
kono
parents: 84
diff changeset
267 f /= 2*g;
3789aef7331d minor fix
kono
parents: 84
diff changeset
268 printf("%d:%g\t",n++,f);
3789aef7331d minor fix
kono
parents: 84
diff changeset
269 f -= 2*g;
3789aef7331d minor fix
kono
parents: 84
diff changeset
270 printf("%d:%g\t",n++,f);
3789aef7331d minor fix
kono
parents: 84
diff changeset
271 f += 2*g;
3789aef7331d minor fix
kono
parents: 84
diff changeset
272 printf("%d:%g\t",n++,f);
3789aef7331d minor fix
kono
parents: 84
diff changeset
273 printf("\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
274
3789aef7331d minor fix
kono
parents: 84
diff changeset
275 n=1;
3789aef7331d minor fix
kono
parents: 84
diff changeset
276 f = 1.3;
3789aef7331d minor fix
kono
parents: 84
diff changeset
277 g = 1.0;
3789aef7331d minor fix
kono
parents: 84
diff changeset
278
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
279 printf("indirect assop ");
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
280 *pg *= 2**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
281 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
282 *pg /= 2**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
283 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
284 *pg -= 2**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
285 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
286 *pg += 2**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
287 printf("%d:%g\t",n++,*pg);
3789aef7331d minor fix
kono
parents: 84
diff changeset
288
3789aef7331d minor fix
kono
parents: 84
diff changeset
289 *pf *= 2**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
290 printf("%d:%g\t",n++,*pf);
3789aef7331d minor fix
kono
parents: 84
diff changeset
291 *pf /= 2**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
292 printf("%d:%g\t",n++,*pf);
3789aef7331d minor fix
kono
parents: 84
diff changeset
293 *pf -= 2**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
294 printf("%d:%g\t",n++,*pf);
3789aef7331d minor fix
kono
parents: 84
diff changeset
295 *pf += 2**pg;
3789aef7331d minor fix
kono
parents: 84
diff changeset
296 printf("%d:%g\t",n++,*pf);
3789aef7331d minor fix
kono
parents: 84
diff changeset
297 printf("\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
298
3789aef7331d minor fix
kono
parents: 84
diff changeset
299
79
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
300 return;
82d0e30f61dd *** empty log message ***
kono
parents:
diff changeset
301 }
94
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
302
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
303 double
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
304 test2(double f,int i)
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
305 {
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
306 double g,h;
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
307
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
308 if (i<=0) return f;
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
309 g = f*2;
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
310 h = f-0.5;
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
311 return h/3-(3.0-(g+3)*test2(f*0.5,i-1)/(h-1));
1ad7045741a7 float dbinop fix
kono
parents: 91
diff changeset
312 }