更新时间:2021-12-21 06:33:40
除非您担心效果,请使用字符串流:
Unless you're worried about performance, use string streams:
std::ostringstream ss;
ss << myFloat;
std::string s(ss.str());
如果您对Boost, lexical_cast<> 是一个方便的选择:
If you're okay with Boost, lexical_cast<> is a convenient alternative:
std::string s = boost::lexical_cast<std::string>(myFloat);
FastFormat 或简单的C风格函数。
Efficient alternatives are e.g. FastFormat or simply the C-style functions.