fix: accuracy loss when convert float to string

This commit is contained in:
2023-11-10 07:29:26 +08:00
parent 33ae0c3367
commit fb9acd28bf

View File

@ -55,7 +55,7 @@ std::string Any2String(const std::any &value) {
std::stringstream buf;
std::string res;
if (auto ptr = std::any_cast<double>(&value)) {
buf << std::setiosflags(std::ios::fixed) << std::setprecision(15) << *ptr;
buf << std::fixed << std::setprecision(310) << *ptr;
} else if (auto ptr = std::any_cast<bool>(&value)) {
if (*ptr)
buf << "True";