Skip to content

Commit

Permalink
Further leverage div_ceil (#689)
Browse files Browse the repository at this point in the history
Followup to #688 which uses `div_ceil` in feature-gated code, which was
missed before
  • Loading branch information
tarcieri authored Oct 8, 2024
1 parent 8f3f9f2 commit c296419
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/uint/boxed/div.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl BoxedUint {
///
/// Variable-time with respect to `rhs`
pub fn div_rem_vartime(&self, rhs: &NonZero<Self>) -> (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"),
Expand All @@ -75,7 +75,7 @@ impl BoxedUint {
///
/// Variable-time with respect to `rhs`.
pub fn 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"),
Expand Down
2 changes: 1 addition & 1 deletion src/uint/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c296419

Please sign in to comment.