title: Rounding doubles - .5 - sprintf
body: <p>I'm using the following code for rounding to 2dp:</p>
  
  <pre><code>sprintf(temp,"%.2f",coef[i]); //coef[i] returns a double
  </code></pre>
  
  <p>It successfully rounds 6.666 to 6.67, but it doesn't work properly when rounding 
  5.555. It returns 5.55, whereas it should (at least in my opinion) return 5.56.</p>
  
  <p>How can I get it to round up when the next digit is 5? i.e. return 5.56.</p>
  
  <p>edit: I now realise that this is happening because when I enter 5.555 with cin it gets
  saved as 5.554999997. </p>
  
  <p>I'm going to try rounding in two stages- first to 3dp and then to 2dp. any other 
  (more elegant) ideas?</p>