Hi i have built an algorithm to calculate pi but i use long float for it so i just get 3.14159 as a result, i need more precision. How? here is the code:
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
long double a, l, p, pi, r;
long long int n, m;
r = 100000;
a = r * sqrt (3) / 2 ;
n = 100000;
m = 6;
while (n > m)
{
a = sqrt (r / 2 * (r + a));
m = m * 2 ;
}
l = sqrt (4 * (pow (r, 2) - pow (a, 2)));
p = m * l;
pi = p / (2 * r) ;
cout << pi << endl;
cout << "number of corners used: " << m << endl;
return 0;
}
By the way there is a 24 core (12 dual core nodes) supercomputer at my high school, just in case