I have an algorithm to calculate pi. However, my compiler (Xcode) is only displaying up to about 5 decimal places. Is there a way to make it display the full precision with or without changing the compiler settings? I have tried looking in the compiler settings although haven't found anything to change the displayed precision. I was thinking of using std::to_string()
in hopes that it would turn the full number into a string, although it didn't. This is my algorithm:
double pi15(int precision){
double output = 0;
for (int n=0;n<=precision;n++){
output += (exp(-1.0,n%2)/exp(1024.0,n))*(-(32.0/(4.0*n+1.0))-(1.0/(4.0*n+3.0))+(256.0/(10.0*n+1.0))-(64.0/(10.0*n+3.0))-(4.0/(10.0*n+5.0))-(4.0/(10.0*n+7.0))+(1.0/(10.0*n+9.0)));
std::cout << std::to_string(output/64) << std::endl;
}
return output/64;
}