   double to string, keeping precision [c++]
  I'm trying to output a double to an Edit Control in a Dialog using the Windows API, which involves converting it to a string first. I've tried using both sprintf and a stringstream, however these only keep 6 decimal places of precision. Is there any way I can get the number in the string to keep more deimal places?   
  You need to include <sstream> and <iomanip> and use something like this (you'll have to use your own width and precision numbers):std::string DtoS(double d){std::stringstream ss;ss << std::setw(5) << std::setfill('0');ss.setf(std::ios::fixed,std::ios::floatfield);ss.precision(1);ss << d;return ss.str();};  That did odd things, I think because it's padding out the number with 0s to the left (so -1 comes out as '0-1.0'). stringstream::precision on its own seems to do what I need though, thanks :-)   ;  One thing to keep in mind is that there is not always a lossless conversion, except when you use more exotic ways to store into the string, like e.g. stuffing the string with all the binary digits of your double. This can get really relevant e.g. when you write a color picker widget.   ;  This should work:#include <string>#include <sstream>#include <iomanip>std::string double2string(double x) {  std::ostringstream oss;  oss << std::setprecision(9999) << x;  return oss.str();}