I wrote a c++ program to calculate pi using the infinite expansion for pi/4. I've used long double but still i get pi = 3.14158 . Where is the extra decimal chopped off. How to correct it? So is this is my code :
#include<iostream>
#include<math.h>
using namespace std;
int main(void)
{
long double pi=1,si,i;
for(i=1;i<100000;i++)
{
si = (pow(-1.0 ,i))/(2*i+1);
pi += si;
}
pi*=4.0;
cout<<" "<< pi <<" \n ";
}