将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

posted @ 2019-08-07 17:43  gd_沐辰  阅读(2823)  评论(0编辑  收藏  举报