使用STL提供的ostringstream很容易解决这个问题,也更自然。新的实现如下:
double num=32.0100;
std::ostringstream oss;
oss<<num;
std::cout<<oss.str()<<std::endl;
输出32.01
使用STL提供的ostringstream很容易解决这个问题,也更自然。新的实现如下:
double num=32.0100;
std::ostringstream oss;
oss<<num;
std::cout<<oss.str()<<std::endl;
输出32.01