[Enhance] use fast_float::from_chars to do str cast to float/double to avoid lose precision (#16190)

This commit is contained in:
HappenLee
2023-02-01 23:53:34 +08:00
committed by GitHub
parent 40d9e19e1d
commit 7c145faa80
2 changed files with 40 additions and 109 deletions

View File

@ -441,7 +441,6 @@ TEST(StringToFloat, Basic) {
std::string double_max = boost::lexical_cast<std::string>(std::numeric_limits<double>::max());
test_float_value<double>(double_min, StringParser::PARSE_SUCCESS);
test_float_value<double>(double_max, StringParser::PARSE_SUCCESS);
// Non-finite values
test_all_float_variants("INFinity", StringParser::PARSE_SUCCESS);
test_all_float_variants("infinity", StringParser::PARSE_SUCCESS);
@ -451,8 +450,8 @@ TEST(StringToFloat, Basic) {
test_float_value_is_nan<double>("nan", StringParser::PARSE_SUCCESS);
test_float_value_is_nan<float>("NaN", StringParser::PARSE_SUCCESS);
test_float_value_is_nan<double>("NaN", StringParser::PARSE_SUCCESS);
test_float_value_is_nan<float>("nana", StringParser::PARSE_SUCCESS);
test_float_value_is_nan<double>("nana", StringParser::PARSE_SUCCESS);
test_float_value_is_nan<float>("nana", StringParser::PARSE_FAILURE);
test_float_value_is_nan<double>("nana", StringParser::PARSE_FAILURE);
test_float_value_is_nan<float>("naN", StringParser::PARSE_SUCCESS);
test_float_value_is_nan<double>("naN", StringParser::PARSE_SUCCESS);