Skip to content

Commit

Permalink
Use countl_zero in bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Sep 30, 2024
1 parent b9ec48d commit db06b0d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -2831,10 +2831,8 @@ class bigint {
FMT_CONSTEXPR20 void assign_pow10(int exp) {
FMT_ASSERT(exp >= 0, "");
if (exp == 0) return *this = 1;
// Find the top bit.
int bitmask = 1;
while (exp >= bitmask) bitmask <<= 1;
bitmask >>= 1;
int bitmask = 1 << (num_bits<unsigned>() -
countl_zero(static_cast<uint32_t>(exp)) - 1);
// pow(10, exp) = pow(5, exp) * pow(2, exp). First compute pow(5, exp) by
// repeated squaring and multiplication.
*this = 5;
Expand Down

0 comments on commit db06b0d

Please sign in to comment.