I am having some issues trying to convert a double to C++ string. Here is my code
std::string doubleToString(double val)
{
std::ostringstream out;
ou
You can also set the minimum width and fill char with STL IO manipulators, like:
out.width( 9 ); out.fill( ' ' );
#include <iomanip>
std::string doubleToString(double val)
{
std::ostringstream out;
out << std::fixed << val;
return out.str();
}
#include <iomanip>
using namespace std;
// ...
out << fixed << val;
// ...
You might also consider using setprecision
to set the number of decimal digits:
out << fixed << setprecision(2) << val;