i'm working on an implementation of the gauss-legendre algorithm to calculate pi and all runs quite smoothly but i was wondering how to get more digits outputted, cout.precision() seems to top out at 17?
i was thinking maybe some sort set of conditionals that will kick it over to another variable or maybe an use an array to hold each digit seperately. any ideas?
precision is not topping out. The capacity for 'double' is.
doubles can only hold so much information. The more decimal places you put on a number, the more information you need. 17 digits requires a lot of memory for a single primitive type. It's more than double can offer you.
You have the following options:
1) accept that double can't get any more precise and settle on a 17 digit value for pi
2) upgrade to 'long double' and get a few more digits for precision
3) abandon primitive types and use something like a bignum library