c++ - std::to_string(double) 的精度

标签 c++ c++11

使用 std::to_string() 将 double 转换为字符串时,有什么方法可以设置结果的精度?

最佳答案

没有。

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.

关于c++ - std::to_string(double) 的精度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14520309/

相关文章:

GCC __attribute__((always_inline)) 和 lambdas,这种语法正确吗?

c++ - 为什么我们使用 enable_shared_from_this 模板?

c++ - 一个类可以有一个没有参数的模板化构造函数吗?

c++ - Delphi中树形 View 中节点的放置位置绘制线

c++ - std::bind 头文件声明

c++ - Visual C++ 10(又名 2010)与 Visual C++ 9(又名 2008)相比

c++ - 为什么这个带模板模板参数的函数编译不通过?

c++ - SFINAE 关于具有默认参数的函数 - 自由函数与运算符()

c++ - 内联命名空间变量是否具有内部链接?如果不是,为什么下面的代码有效?

c++ - 使用 braced-init 初始化 std::shared_ptr<std::map<>>