C++11 std::to_string(double) - No trailing zeros

前端 未结 9 1802
孤城傲影
孤城傲影 2020-12-01 06:04

Today I tried out some new functions of the C++11 STL and encountered std::to_string.

Lovely, lovely set of functions. Creating a stringstream object fo

9条回答
  •  春和景丽
    2020-12-01 06:42

    std::to_string gives you no control over the format; you get the same result as sprintf with the appropriate format specifier for the type ("%f" in this case).

    If you need more flexibility, then you will need a more flexible formatter - such as std::stringstream.

提交回复
热议问题