diff --git a/src/uint/boxed/div.rs b/src/uint/boxed/div.rs index 6663991f..0dd18c45 100644 --- a/src/uint/boxed/div.rs +++ b/src/uint/boxed/div.rs @@ -50,7 +50,7 @@ impl BoxedUint { /// /// Variable-time with respect to `rhs` pub fn div_rem_vartime(&self, rhs: &NonZero) -> (Self, Self) { - let yc = ((rhs.0.bits_vartime() + Limb::BITS - 1) / Limb::BITS) as usize; + let yc = rhs.0.bits_vartime().div_ceil(Limb::BITS) as usize; match yc { 0 => panic!("zero divisor"), @@ -75,7 +75,7 @@ impl BoxedUint { /// /// Variable-time with respect to `rhs`. pub fn rem_vartime(&self, rhs: &NonZero) -> Self { - let yc = ((rhs.0.bits_vartime() + Limb::BITS - 1) / Limb::BITS) as usize; + let yc = rhs.0.bits_vartime().div_ceil(Limb::BITS) as usize; match yc { 0 => panic!("zero divisor"), diff --git a/src/uint/encoding.rs b/src/uint/encoding.rs index fb316809..b83899a5 100644 --- a/src/uint/encoding.rs +++ b/src/uint/encoding.rs @@ -532,7 +532,7 @@ pub(crate) fn radix_encode_limbs_mut_to_string(radix: u32, limbs: &mut [Limb]) - let mut out; if radix.is_power_of_two() { let bits = radix.trailing_zeros() as usize; - let size = (limbs.len() * Limb::BITS as usize + bits - 1) / bits; + let size = (limbs.len() * Limb::BITS as usize).div_ceil(bits); out = vec![0u8; size]; radix_encode_limbs_by_shifting(radix, limbs, &mut out[..]); } else {