將double轉化成string,並保持N位小數


double dumpSize = (1024000000.1415926535897932384 * 1.0) / 1024 / 1024;
string tempStr = to_string(dumpSize);
std::stringstream ss;
ss << setiosflags(ios::fixed) << std::setprecision(1) << dumpSize;  //此處1代表保存N為小數
tempStr = ss.str();

 

#ifdef _UNICODE
typedef wstring tstring;
#else
typedef std::string tstring;
#endif


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM