设置double精度
在这里插入代码片
#include <iomanip>
#include <sstream>
int main()
{
double mDouble = 3.14159269482786273648;
cout<<fixed<<setprecision(3)<<mDouble <<endl;
return 0;
}
double StrToD(string str)
{
double tempD= atof(str);
std::stringstream ss;
ss << std::setiosflags(std::ios::fixed) << std::setprecision(3) << tempD;
return tempD;
}
string DoubleToStringByStringStream(double value)
{
std::ostringstream stream;
stream << value;
return stream.str();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)