Source code cleanup.

parent 884ffe97
...@@ -6,28 +6,26 @@ ...@@ -6,28 +6,26 @@
// That series comes from this series: // That series comes from this series:
// ex=1+x/1!+x2/2!+x3/3!+x4/4!+... // ex=1+x/1!+x2/2!+x3/3!+x4/4!+...
int fact(int x) {return x > 0 ? x * fact(x-1) : 1; } int fact(int x) {
return x > 0 ? x * fact(x-1) : 1;
}
int main(void) { int main(void) {
float last_e, e; float last_e, e;
int i, max_first = fact(8), max_last = fact(7); int i, max_first = fact(8), max_last = fact(7);
e = 1; for(e = 1.f, i = 1; i < max_first; i *= i+1 )
for(i = 1; i < max_first; i *= i+1 ) {
e += 1.f / i; e += 1.f / i;
}
last_e = e; last_e = e;
e = 1;
for(i = 1; i < max_last; i *= i+1 ) { for(e = 1.f, i = 1; i < max_last; i *= i+1 )
e += 1.f / i; e += 1.f / i;
}
if( last_e < e + 1.f / (i*8) ) if( last_e < e + 1.f / (i*8) )
printf("more precision detected!\n"); printf("more precision detected!\n");
printf("diff:\n%.80f\n%.80f \n", last_e, e + 1.f / (i*8)); printf("diff:\n%.80f\n%.80f \n", last_e, e + 1.f / (i*8));
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment