title: Does setprecision in c++ round? If so why am I seeing this?
body: <p>The following snippet outputs 0.29847 when I would have expected 0.29848:</p>
  
  <pre><code>double f = 0.298475;
  cout &lt;&lt; setprecision(5) &lt;&lt; f &lt;&lt; endl;
  </code></pre>
  
  <p>For other examples, however, I observe rounding:</p>
  
  <pre><code>double f = 0.123459;
  cout &lt;&lt; setprecision(5) &lt;&lt; f &lt;&lt; endl;
  </code></pre>
  
  <p>outputs: 0.12346</p>
  
  <p>and </p>
  
  <pre><code>double f = 0.123454;
  cout &lt;&lt; setprecision(5) &lt;&lt; f &lt;&lt; endl;
  </code></pre>
  
  <p>outputs: 0.12345</p>