设置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();
}