title: Why is not the output precision being rounded correctly?
body: <p>I have tested the following code to verify some simple numerical outputs when <code>std::setprecision</code> is used in C++:</p>
  
  <pre><code>double f1 = 3.1415;
  std::cout &lt;&lt; std::setprecision(4) &lt;&lt; f1 &lt;&lt; '\n';
  double f2 = 1.2345;
  std::cout &lt;&lt; std::setprecision(4) &lt;&lt; f2 &lt;&lt; '\n';
  </code></pre>
  
  <p>The corresponding outputs are:</p>
  
  <pre><code>3.142
  1.234
  </code></pre>
  
  <p>Why is 1.234 not being rounded to 1.235?  Furthermore, if we change <code>f2</code> to 1.2315, then the rounding in the output does happen, and the output is 1.232.  Is there any rule of thumb to follow when using <code>setprecision</code> to format the output of numeric values?</p>