diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index cc4b06efaaa28..1d73c720a13f2 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -8,8 +8,6 @@ #ifndef FMT_FORMAT_INL_H_ #define FMT_FORMAT_INL_H_ -#include "format.h" - #include #include #include @@ -18,7 +16,9 @@ #include #include // for std::memmove #include -#include // for std::uninitialized_fill_n +#include // for std::uninitialized_fill_n + +#include "format.h" #if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) # include #endif @@ -482,10 +482,10 @@ inline fp operator*(fp x, fp y) { return {multiply(x.f, y.f), x.e + y.e + 64}; } FMT_FUNC fp get_cached_power(int min_exponent, int& pow10_exponent) { const uint64_t one_over_log2_10 = 0x4d104d42; // round(pow(2, 32) / log2(10)) int index = static_cast( - static_cast( - static_cast(min_exponent + fp::significand_size - 1) * one_over_log2_10 + - ((1ULL << 32) - 1) // ceil - ) >> + (static_cast(min_exponent + fp::significand_size - 1) * + one_over_log2_10 + + ((1ULL << 32) - 1) // ceil + ) >> 32 // arithmetic shift ); // Decimal exponent of the first (smallest) cached power of 10. @@ -550,8 +550,7 @@ class bigint { FMT_ASSERT(compare(*this, other) >= 0, ""); bigit borrow = 0; size_t i = static_cast(other.exp_ - exp_); - for (size_t j = 0, n = other.bigits_.size(); j != n; - ++i, ++j) { + for (size_t j = 0, n = other.bigits_.size(); j != n; ++i, ++j) { subtract_bigits(i, other.bigits_[j], borrow); } while (borrow > 0) subtract_bigits(i, 0, borrow); @@ -641,8 +640,8 @@ class bigint { size_t i = lhs.bigits_.size(); size_t j = rhs.bigits_.size(); while ((i != 0) && (j != 0)) { - -- i; - -- j; + --i; + --j; bigit lhs_bigit = lhs.bigits_[i], rhs_bigit = rhs.bigits_[j]; if (lhs_bigit != rhs_bigit) return lhs_bigit > rhs_bigit ? 1 : -1; } @@ -658,7 +657,9 @@ class bigint { if (max_lhs_bigits + 1 < num_rhs_bigits) return -1; if (max_lhs_bigits > num_rhs_bigits) return 1; auto get_bigit = [](const bigint& n, int i) -> bigit { - return i >= n.exp_ && i < n.num_bigits() ? n.bigits_[static_cast(i - n.exp_)] : 0; + return i >= n.exp_ && i < n.num_bigits() + ? n.bigits_[static_cast(i - n.exp_)] + : 0; }; double_bigit borrow = 0; int min_exp = (std::min)((std::min)(lhs1.exp_, lhs2.exp_), rhs.exp_); @@ -704,7 +705,7 @@ class bigint { for (size_t bigit_index = 0; bigit_index < num_bigits; ++bigit_index) { // Compute bigit at position bigit_index of the result by adding // cross-product terms n[i] * n[j] such that i + j == bigit_index. - for (size_t i = 0; i <= bigit_index; ++ i) { + for (size_t i = 0; i <= bigit_index; ++i) { // Most terms are multiplied twice which can be optimized in the future. sum += static_cast(n[i]) * n[bigit_index - i]; } @@ -735,7 +736,8 @@ class bigint { const auto exp_difference = static_cast(exp_ - divisor.exp_); // Align bigints by adding trailing zeros to simplify subtraction. bigits_.resize(num_bigits + exp_difference); - std::memmove(&bigits_[exp_difference], &bigits_[0], num_bigits * sizeof(bigits_[0])); + std::memmove(&bigits_[exp_difference], &bigits_[0], + num_bigits * sizeof(bigits_[0])); std::uninitialized_fill_n(bigits_.data(), exp_difference, 0); exp_ = divisor.exp_; }