From 027fcaf05e81dc0a4977638aaa273fc82c1d5d45 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 26 Sep 2021 08:44:05 -0700 Subject: [PATCH] Replace use_grisu with fallback since Grisu is only one of multiple implemented algorithms --- include/fmt/core.h | 2 +- include/fmt/format-inl.h | 2 +- include/fmt/format.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 37b01802..2bac1cb3 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -2676,7 +2676,7 @@ struct float_specs { bool upper : 1; bool locale : 1; bool binary32 : 1; - bool use_grisu : 1; + bool fallback : 1; bool showpoint : 1; }; diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 7175fcc7..e5cd0ea6 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -2375,7 +2375,7 @@ FMT_HEADER_ONLY_CONSTEXPR20 int format_float(Float value, int precision, return -precision; } - if (!specs.use_grisu) return snprintf_float(value, precision, specs, buf); + if (specs.fallback) return snprintf_float(value, precision, specs, buf); if (!is_constant_evaluated() && precision < 0) { // Use Dragonbox for the shortest format. diff --git a/include/fmt/format.h b/include/fmt/format.h index dd0006bc..9eeffcde 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1995,7 +1995,7 @@ FMT_CONSTEXPR20 auto write(OutputIt out, T value, ++precision; } if (const_check(std::is_same())) fspecs.binary32 = true; - fspecs.use_grisu = is_fast_float(); + if (!is_fast_float()) fspecs.fallback = true; int exp = format_float(promote_float(value), precision, fspecs, buffer); fspecs.precision = precision; auto fp = big_decimal_fp{buffer.data(), static_cast(buffer.size()), exp};