函数将双精度值格式化为字符串

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了函数将双精度值格式化为字符串相关的知识,希望对你有一定的参考价值。

This function shows how you can format a double value to a string with a given precision.
  1. std::string formatToString(int precision, double dValue)
  2. {
  3. CString sTmpVal;
  4. CString sFormat;
  5. sFormat.Format("%%.%df", precision);
  6. sTmpVal.Format(sFormat, dValue);
  7. return static_cast<LPCSTR>(sTmpVal);
  8. }

以上是关于函数将双精度值格式化为字符串的主要内容,如果未能解决你的问题,请参考以下文章