mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-21 18:20:04 +00:00
Use countl_zero in bigint
This commit is contained in:
parent
b9ec48d9ca
commit
db06b0df87
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user