-1
我有一个小功能,双转换到的std :: string:如何在将科学记数法追加到ostringstream时关闭它?
std::string convertDoubleToString(double value) {
std::ostringstream ostr;
ostr << value;
return ostr.str();
}
我不想在这里用科学记数法。我如何在这种情况下做到这一点?我可以使用std :: fixed或cout.setprecision,但它仅适用于std :: cout,但是如何将它用于我的情况?
是什么让你觉得它仅适用于'cout'?你试过了吗? – NathanOliver
流是一个流是一个流......并且所有流基本上与[操纵器](http://en.cppreference.com/w/cpp/io/manip)相同。 –
顺便说一句,你可能想看看['std :: to_string'](http://en.cppreference.com/w/cpp/string/basic_string/to_string)。 –