Is there any way to set the precision of the result when converting a double to string using std::to_string()?
std::to_string()
No.
Returns: Each function returns a string object holding the character representation of the value of its argument that would be generated by calling sprintf(buf, fmt, val) with a format specifier of "%d", "%u", "%ld", "%lu", "%lld", "%llu", "%f", "%f", or "%Lf", respectively, where buf designates an internal character buffer of sufficient size.
sprintf(buf, fmt, val)
"%d"
"%u"
"%ld"
"%lu"
"%lld"
"%llu"
"%f"
"%Lf"
2.1m questions
2.1m answers
60 comments
57.0k users