From 1f58f2047a00c51a6c3d33c2088851dbfde6964a Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Wed, 31 Dec 2025 20:43:22 +0000 Subject: [PATCH] uucore: switch to `u64::ilog2` `u64::ilog2` has been available since Rust 1.67; MSRV is 1.85. https://doc.rust-lang.org/std/primitive.u64.html#method.ilog2 --- src/uucore/src/lib/features/parser/num_parser.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/uucore/src/lib/features/parser/num_parser.rs b/src/uucore/src/lib/features/parser/num_parser.rs index 178cd578fba..7d799b9881f 100644 --- a/src/uucore/src/lib/features/parser/num_parser.rs +++ b/src/uucore/src/lib/features/parser/num_parser.rs @@ -432,8 +432,7 @@ fn pow_with_context(bd: &BigDecimal, exp: i64, ctx: &Context) -> BigDecimal { // Count the number of multiplications we're going to perform, one per "1" binary digit // in exp, and the number of times we can divide exp by 2. let mut n = exp.unsigned_abs(); - // Note: 63 - n.leading_zeros() == n.ilog2, but that's only available in recent Rust versions. - let muls = (n.count_ones() + (63 - n.leading_zeros()) - 1) as u64; + let muls = (n.count_ones() + n.ilog2() - 1) as u64; // Note: div_ceil would be nice to use here, but only available in recent Rust versions. // (see note above about minimum Rust version in use) let margin_extra = (muls + MUL_PER_MARGIN_EXTRA / 2) / MUL_PER_MARGIN_EXTRA;