add a few asserts to make approximating pi more reliable

master
neingeist 11 years ago
parent 2531b2b3c5
commit f1adfa76d9

@ -1,3 +1,4 @@
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
@ -19,7 +20,12 @@ double approximate_pi(unsigned int steps) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
// printf("sizeof(int) = %d\n", sizeof(int)); // printf("sizeof(int) = %d\n", sizeof(int));
printf("pi = %8.7f\n", approximate_pi(10000000));
double mypi = approximate_pi(100000000);
printf("pi = %8.7f\n", mypi);
assert(mypi > 3.141);
assert(mypi < 3.142);
return 0; return 0;
} }

Loading…
Cancel
Save