title: C++ calculating more precise than double or long double
body: <p>I'm teaching myself C++ and on <a href="http://www.reddit.com/r/dailyprogrammer/comments/pp53w/2142012_challenge_6_easy/" rel="noreferrer">this practice question</a> it asks to write code that can calculate PI to >30 digits. I learned that double / long double are both 16 digits precise on my computer. </p>
  
  <p>I think the lesson of this question is to be able to calculate precision beyond what is available. Therefore how do I do this? Is it possible?</p>
  
  <p>my code for calculating Pi right now is </p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;math.h&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  int main(){ 
  
      double pi;
      pi = 4*atan(1.0);
      cout&lt;&lt;setprecision(30)&lt;&lt;pi;
      return 0;
  }
  </code></pre>
  
  <p>Output is to 16 digits and pi to 30 digits is listed below for comparison.</p>
  
  <pre><code>3.1415926535897931
  3.141592653589793238462643383279
  </code></pre>
  
  <p>Any suggestions for increasing precision or is this something that won't matter ever? Alternatively if there is another lesson you think I should be learning here feel free to offer it. Thank you!</p>