Révision 21 Pi/C/Simple/Pi.c
Pi.c (revision 21) | ||
---|---|---|
40 | 40 |
float y=MWCfp ; |
41 | 41 |
|
42 | 42 |
// Matching test |
43 |
|
|
44 |
#ifdef IFSQRT |
|
45 |
if ( sqrt(x*x+y*y) < 1.0f ) { |
|
46 |
total+=1; |
|
47 |
} |
|
48 |
#elif IFWOSQRT |
|
49 |
if ( (x*x+y*y) < 1.0f ) { |
|
50 |
total+=1; |
|
51 |
} |
|
52 |
#else |
|
43 | 53 |
int inside=((x*x+y*y) < 1.0f) ? 1:0; |
44 | 54 |
total+=inside; |
55 |
#endif |
|
56 |
|
|
45 | 57 |
} |
46 | 58 |
|
47 | 59 |
return(total); |
... | ... | |
62 | 74 |
|
63 | 75 |
float pi=(float)MainLoopGlobal(iterations,seed_w,seed_z)/(float)iterations*4; |
64 | 76 |
|
65 |
printf("\tPi=%f with error %f and %lu iterations\n\n",pi,
|
|
77 |
printf("\tPi=%.40f\n\twith error %.40f\n\twith %lu iterations\n\n",pi,
|
|
66 | 78 |
fabs(pi-4*atan(1))/pi,(unsigned long)iterations); |
67 | 79 |
|
68 | 80 |
} |
Formats disponibles : Unified diff