It is not possible to change the accuracy using to_string() , but instead, you can use the setprecision IO manipulator instead:
#include <sstream> #include <iomanip> template <typename T> std::string to_string_with_precision(const T a_value, const int n = 6) { std::ostringstream out; out << std::setprecision(n) << a_value; return out.str(); }
hmjd May 17 '13 at 9:50 a.m. 2013-05-17 09:50
source share