From c5b445f6f20fccb6aa3c56e044a2dc6f0492dead Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sun, 1 Jun 2025 19:27:06 +0200 Subject: [PATCH] uucore: num_parser: Clarify origin of pow_with_context And why we use an older minimum Rust version in that piece of code. --- src/uucore/src/lib/features/parser/num_parser.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/uucore/src/lib/features/parser/num_parser.rs b/src/uucore/src/lib/features/parser/num_parser.rs index c657b3ade..84aa82bdd 100644 --- a/src/uucore/src/lib/features/parser/num_parser.rs +++ b/src/uucore/src/lib/features/parser/num_parser.rs @@ -384,6 +384,8 @@ fn make_error<'a>(overflow: bool, negative: bool) -> ExtendedParserError<'a, Ext // // TODO: Still pending discussion in https://github.com/akubera/bigdecimal-rs/issues/147, // we do lose a little bit of precision, and the last digits may not be correct. +// Note: This has been copied from the latest revision in https://github.com/akubera/bigdecimal-rs/pull/148, +// so it's using minimum Rust version of `bigdecimal-rs`. fn pow_with_context(bd: &BigDecimal, exp: i64, ctx: &Context) -> BigDecimal { if exp == 0 { return 1.into(); @@ -412,6 +414,7 @@ fn pow_with_context(bd: &BigDecimal, exp: i64, ctx: &Context) -> BigDecimal { // 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; // 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; let mut margin = margin_extra + MARGIN_PER_MUL * muls;