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"
1.4m articles
1.4m replys
5 comments
57.0k users