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.,
123456.789123456789 should give 123456.7891234568, but 123456 should not give 123456.0000000000, but rather 123456
So far i've narrowed it down to:
long double myNumber;
string myString;
ostringstream myStream;
myStream.setf(ios::fixed,ios::floatfield);
myStream.precision(10);
myStream << myNumber;
myString = myStream.str();
I've also tried fiddling with setfill(' ') and std::ws but can't really get the hang of it. Any suggestions?