Révision 159
Pi/C/Simple/Pi_Simple.c (revision 159) | ||
---|---|---|
18 | 18 |
#define CONG (jcong=69069*jcong+1234567) |
19 | 19 |
#define KISS ((MWC^CONG)+SHR3) |
20 | 20 |
|
21 |
#define MWCfp MWC * 2.328306435454494e-10f
|
|
22 |
#define KISSfp KISS * 2.328306435454494e-10f
|
|
23 |
#define SHR3fp SHR3 * 2.328306435454494e-10f
|
|
24 |
#define CONGfp CONG * 2.328306435454494e-10f
|
|
21 |
#define MWCfp (float)MWC*2.3283064365386963e-10f
|
|
22 |
#define KISSfp (float)KISS*2.328306435454494e-10f
|
|
23 |
#define SHR3fp (float)SHR3*2.328306435454494e-10f
|
|
24 |
#define CONGfp (float)CONG*2.328306435454494e-10f
|
|
25 | 25 |
|
26 | 26 |
#define ITERATIONS 1000000000 |
27 | 27 |
|
... | ... | |
83 | 83 |
unsigned long y=(unsigned long)(KISS>>1) ; |
84 | 84 |
#endif |
85 | 85 |
#elif defined TFP32 |
86 |
#define THEONE 1.0f
|
|
86 |
#define THEONE (float)1.0f
|
|
87 | 87 |
#if defined TCONG |
88 | 88 |
float x=CONGfp ; |
89 | 89 |
float y=CONGfp ; |
... | ... | |
98 | 98 |
float y=KISSfp ; |
99 | 99 |
#endif |
100 | 100 |
#elif defined TFP64 |
101 |
#define THEONE 1.0f
|
|
101 |
#define THEONE (double)1.0f
|
|
102 | 102 |
#if defined TCONG |
103 | 103 |
double x=(double)CONGfp ; |
104 | 104 |
double y=(double)CONGfp ; |
... | ... | |
123 | 123 |
|
124 | 124 |
int main(int argc, char *argv[]) { |
125 | 125 |
|
126 |
unsigned int seed_w=1010,seed_z=2008;
|
|
126 |
unsigned int seed_w=110271,seed_z=101008;
|
|
127 | 127 |
LENGTH iterations=ITERATIONS,inside=0; |
128 | 128 |
|
129 | 129 |
if (argc > 1) { |
... | ... | |
148 | 148 |
|
149 | 149 |
float pi=4.*(float)inside/(float)iterations; |
150 | 150 |
|
151 |
printf("\tPi=%f with error %f and %lld iterations\n\n",pi, |
|
152 |
fabs(pi-4*atan(1))/pi,(long long)iterations); |
|
151 |
printf("\t%lld inside for %lld iterations\n", |
|
152 |
(long long)inside,(long long)iterations); |
|
153 |
printf("\tPi=%f with error %f\n\n", |
|
154 |
pi,fabs(pi-4*atan(1))/pi); |
|
153 | 155 |
|
154 | 156 |
} |
Formats disponibles : Unified diff