title: Trying to extend my result to have 8 digits after a decimal
body: <p>I'm trying to extend the result on my program to 8 digits after the decimal point. I went over this page (<a href="http://www.cplusplus.com/reference/ios/ios_base/precision/" rel="nofollow">http://www.cplusplus.com/reference/ios/ios_base/precision/</a>) but I'm not having any luck changing the result. Any suggestions? Thanks you. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;math.h&gt;
  
  using namespace std;
  
  long double taylorSeriesToCalculateCosine(long double x, int degree);
  long factorial( int input );
  
  int main(int argc, const char * argv[])
  {
      cout &lt;&lt; "Cosine of .3: ";
      cout &lt;&lt; taylorSeriesToCalculateCosine(.3,3) &lt;&lt; endl;
  
      return 0;
  }
  
  // taylor series to calculate cosine
  long double taylorSeriesToCalculateCosine(long double x,int degree){
  
      int i = 0;
      long double accumulation = 0;
      int cosInputArray[4] = {1,0,-1,0};
  
      while (i &lt; degree) {
  
          int input = cosInputArray[i%4];
  
          accumulation += input*((pow(x, i))/factorial(i)); 
          i++;
      }
  
      return accumulation;
  }
  </code></pre>
  
  <p>OUTPUT: </p>
  
  <pre><code>Cosine of .3: 0.955
  </code></pre>