title: Using stringstream precision to format floats but discarding zero-padding
body: <p>I'm trying to set precision (i.e. number of decimal places) of floats and long doubles to 10, but i don't want them zero padded. I.e., </p>
  
  <p>123456.789123456789 should give 123456.7891234568, but
  123456 should not give 123456.0000000000, but rather 123456</p>
  
  <p>So far i've narrowed it down to:</p>
  
  <pre><code>long double myNumber;
  string myString;
  ostringstream myStream;
  myStream.setf(ios::fixed,ios::floatfield);
  myStream.precision(10);
  myStream &lt;&lt; myNumber;
  myString = myStream.str();
  </code></pre>
  
  <p>I've also tried fiddling with setfill(' ') and std::ws but can't really get the hang of it.
  Any suggestions?</p>