使用STL提供的ostringstream删除float转string时最后的0

使用STL提供的ostringstream很容易解决这个问题,也更自然。新的实现如下: 

double num=32.0100;

std::ostringstream oss;

oss<<num;

std::cout<<oss.str()<<std::endl;

输出32.01

猜你喜欢

转载自blog.csdn.net/v6543210/article/details/81562346