aboutsummaryrefslogtreecommitdiff
path: root/include/fmt/format.h
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2019-12-05 18:51:48 -0800
committerHaibo Huang <hhb@google.com>2019-12-05 18:51:48 -0800
commit289bd9700073441c2086388c1dc85aa3daea4e08 (patch)
tree44ba216844db84101d41a89caf81cbf61f5f0dbe /include/fmt/format.h
parent71aa0b1047729072861452eda91eaa957d95c9ce (diff)
parent071794ec654a7c503b6214de4032c8ec8a07440b (diff)
downloadfmtlib-289bd9700073441c2086388c1dc85aa3daea4e08.tar.gz
Upgrade fmtlib to 6.1.1
Test: None Change-Id: I9c63d6e62c440cffb6914d9edd77bd7632ec1ca2
Diffstat (limited to 'include/fmt/format.h')
-rw-r--r--include/fmt/format.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/fmt/format.h b/include/fmt/format.h
index 398c2a77..600b0eba 100644
--- a/include/fmt/format.h
+++ b/include/fmt/format.h
@@ -1145,10 +1145,11 @@ template <typename Char> class float_writer {
if (specs_.format == float_format::exp) {
// Insert a decimal point after the first digit and add an exponent.
*it++ = static_cast<Char>(*digits_);
- if (num_digits_ > 1) *it++ = decimal_point_;
- it = copy_str<Char>(digits_ + 1, digits_ + num_digits_, it);
int num_zeros = specs_.precision - num_digits_;
- if (num_zeros > 0 && specs_.trailing_zeros)
+ bool trailing_zeros = num_zeros > 0 && specs_.trailing_zeros;
+ if (num_digits_ > 1 || trailing_zeros) *it++ = decimal_point_;
+ it = copy_str<Char>(digits_ + 1, digits_ + num_digits_, it);
+ if (trailing_zeros)
it = std::fill_n(it, num_zeros, static_cast<Char>('0'));
*it++ = static_cast<Char>(specs_.upper ? 'E' : 'e');
return write_exponent<Char>(full_exp - 1, it);