title: Issue while rounding decimal fileds in C++ using setprecision
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/10922366/does-setprecision-in-c-round-if-so-why-am-i-seeing-this">Does setprecision in c++ round? If so why am I seeing this?</a>  </p>
  </blockquote>
  
  
  
  <p>Here is the function I'm using</p>
  
  <pre><code>char* round(double value, int decimal_places)
  {
  decimal_places = decimal_places+1;
  std::stringstream s2;
     s2 &lt;&lt; std::setprecision(decimal_places) &lt;&lt; std::setiosflags(std::ios_base::fixed) &lt;&lt; value;
  std::string st = s2.str();
    return st;
  }
  </code></pre>
  
  <p><strong>My input value is 0.89425 and the number of decimal palaces is 4</strong></p>
  
  <p>My output is 0.8942 but i want 0.8943 i.e., if next digit after my required decimal places is >= 5 then the output should be rounded to the next value.</p>