保留double数据的n个有效位C++
template <typename T1, typename T2>
inline double setDoublePrecicious(const T1 &number, const T2 &n){
stringstream str_number;
str_number<<std::setprecision(n)<<number;
std::string string_number = str_number.str();
str_number.clear();
str_number.str("");
return std::atof(string_number.c_str());
}