float x = box.center.x;
std::stringstream ss_x;
ss_x << std::setiosflags(std::ios::fixed) << std::setprecision(3) << x;
std::string str_x = ss_x.str();
std::cout << str_x << std::endl;
float y = box.center.y;
std::stringstream ss_y;
ss_y << std::setiosflags(std::ios::fixed) << std::setprecision(3) << y;
std::string str_y = ss_y.str();
std::cout << str_y << std::endl;
c++ 浮点型转string并保留指定位小数
最新推荐文章于 2024-07-25 07:24:01 发布