From ce98e0c6a0fcefe6d081db82de8516c7062492f7 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 3 Nov 2020 19:19:10 -0800 Subject: [PATCH 1/3] Fix fallback float formatter at assymetric bounds (#1976) --- include/fmt/format-inl.h | 2 +- test/format-test.cc | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 5d466eeb..8f2fe735 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -2337,7 +2337,7 @@ void fallback_format(Double d, int num_digits, bool binary32, buffer& buf, upper = &upper_store; } denominator.assign_pow10(exp10); - denominator <<= 1; + denominator <<= shift; } else if (exp10 < 0) { numerator.assign_pow10(-exp10); lower.assign(numerator); diff --git a/test/format-test.cc b/test/format-test.cc index 128b57a2..0f87a23c 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1270,6 +1270,8 @@ TEST(FormatterTest, FormatDouble) { EXPECT_EQ(buffer, format("{:a}", -42.0)); safe_sprintf(buffer, "%A", -42.0); EXPECT_EQ(buffer, format("{:A}", -42.0)); + EXPECT_EQ("9223372036854775808.000000", + format("{:f}", 9223372036854775807.0)); } TEST(FormatterTest, PrecisionRounding) { From e4eb242ce8197e81919ff11d9d2255fd694e708f Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 3 Nov 2020 21:20:53 -0800 Subject: [PATCH 2/3] Update changelog and bump version --- ChangeLog.rst | 6 ++++++ include/fmt/core.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog.rst b/ChangeLog.rst index a5b776cf..ce65a178 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,3 +1,9 @@ +7.1.2 - TBD +----------- + +* Fixed floating point formatting with large precision + (`#1976 `_). + 7.1.1 - 2020-11-01 ------------------ diff --git a/include/fmt/core.h b/include/fmt/core.h index 60e49425..262a94f9 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -18,7 +18,7 @@ #include // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 70101 +#define FMT_VERSION 70102 #ifdef __clang__ # define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) From cc09f1a6798c085c325569ef466bcdcffdc266d4 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 4 Nov 2020 06:50:09 -0800 Subject: [PATCH 3/3] Update version --- ChangeLog.rst | 4 ++-- doc/build.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog.rst b/ChangeLog.rst index ce65a178..26bb8646 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,5 +1,5 @@ -7.1.2 - TBD ------------ +7.1.2 - 2020-11-04 +------------------ * Fixed floating point formatting with large precision (`#1976 `_). diff --git a/doc/build.py b/doc/build.py index 85eaaa81..bae311d4 100755 --- a/doc/build.py +++ b/doc/build.py @@ -6,7 +6,7 @@ import errno, os, shutil, sys, tempfile from subprocess import check_call, check_output, CalledProcessError, Popen, PIPE from distutils.version import LooseVersion -versions = ['1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0', '4.1.0', '5.0.0', '5.1.0', '5.2.0', '5.2.1', '5.3.0', '6.0.0', '6.1.0', '6.1.1', '6.1.2', '6.2.0', '6.2.1', '7.0.0', '7.0.1', '7.0.2', '7.0.3', '7.1.0', '7.1.1'] +versions = ['1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0', '4.1.0', '5.0.0', '5.1.0', '5.2.0', '5.2.1', '5.3.0', '6.0.0', '6.1.0', '6.1.1', '6.1.2', '6.2.0', '6.2.1', '7.0.0', '7.0.1', '7.0.2', '7.0.3', '7.1.0', '7.1.1', '7.1.2'] def pip_install(package, commit=None, **kwargs): "Install package using pip."