1  std:to_string()方法只能精确到6位小数点

double d = 3.1415926535897932384;
std::string str = std::to_string(d);
std::cout << str << std::endl; // 3.141593

2 使用stringstream,在输入流时使用setprecision设置精度

 std::stringstream ss;
 ss << std::setprecision(15) << d;
 str = ss.str();  // 3.14159265358979
 std::cout << str << std::endl; //3.14159265358979

3 使用QString的number函数

QString QString::number(double n, char format = 'g', int precision = 6)

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
相关资源
相似解决方案