I\' d like to use lexical_cast to convert a float to a string. Usually it works fine, but I have some problems with numbers without decimal. How can I fix numbe
Have a look at boost::format library. It merges the usability of printf with type safety of streams. For speed, I do not know, but I doubt it really matters nowadays.
#include
#include
int main()
{
double x = 5.0;
std::cout << boost::str(boost::format("%.2f") % x) << '\n';
}