title: How to properly print a double to cout in C++
body: <p>I've had a look at some questions before posting this and couldn't find what I was looking for, so if it's a duplicate I'm sorry.</p>
  
  <p>I have this code:</p>
  
  <pre><code>cout &lt;&lt; "The balance at year " &lt;&lt; i &lt;&lt; " will be " &lt;&lt; char(156) &lt;&lt; std::setprecision(2)
       &lt;&lt; balance &lt;&lt; endl;
  </code></pre>
  
  <p>To my knowledge this should print to the console something like:</p>
  
  <pre><code>£2.00
  £100.46
  </code></pre>
  
  <p>*fyi Above are just examples I know there's nothing to suggest those numbers, but the format should look like that, right? </p>
  
  <p>But here's my output:</p>
  
  <pre><code>£1e+002
  £1.1e+002
  </code></pre>
  
  <p>Why is it doing this?</p>
  
  <p>It was my understanding that using <code>setprecision</code> would show 2 decimal places and nothing more. </p>
  
  <p>Oh and also noticed hardly any questions about printing doubles that said use <code>setprecision</code> actually state that this needs including:</p>
  
  <pre><code>#include &lt;iomanip&gt;
  </code></pre>