title: While loop with precision as condition
body: <p>Is it possible to do a while loop in C++ until a decimal reaches a certain precision? I want to do a long calculation for arctan and then pi and I want the loop to run until pi is calculated to the 10th decimal place using the formula pi=4(arctan (1.0)). I'm manually calculating arctan using the taylor series formula. I know there are built in functions for these calculations but this is a homework assignment so I have to do it this way. I'm not looking for the solution to the problem, just whether or not a loop using precision is possible. Thanks!</p>
  
  <p>Edit:</p>
  
  <p>I'm still stuck with this! I can't come up with a proper argument for the while loop, even after going over everybody's hints. Really need help. Here's the code I have come up with:</p>
  
  <pre><code>#include &lt;iomanip&gt;
  #include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;cmath&gt;
  
  using namespace std;
  
  int main(void)
  {
   int i;
   long double result;
   long double pi;
   int y=3;
   int loopcount=0;
   long double precision;
  
     cout&lt;&lt;"Start\n";
  
     result=1-(pow(1,y)/y);
  
    do
      {
       y=y+2;
       result=result+(pow(1,y)/y);
       y=y+2;
       result=result-(pow(1,y)/y);
  
        pi=4*(result);
        precision=(pi*(pow(10,11))/10);
  
        loopcount++;
      }
    while(//This is the problem!);
  
    cout&lt;&lt;"Final Arctan is:"&lt;&lt;endl;
       cout&lt;&lt;setprecision(20)&lt;&lt;result&lt;&lt;endl;
    cout&lt;&lt;"Final Pi is:"&lt;&lt;endl;
         cout&lt;&lt;setprecision(9)&lt;&lt;pi1&lt;&lt;endl;
    cout&lt;&lt;"Times looped:"&lt;&lt;endl;
         cout&lt;&lt;loopcount&lt;&lt;endl;
  
  return 0;
  }
  </code></pre>