Skip to content

Commit

Permalink
chore: modify if condition to comparing msbs directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo-Dallegri committed Dec 17, 2024
1 parent 2fd30f9 commit ecb9dec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/fns/unconstrained_ops.nr
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ pub(crate) unconstrained fn __udiv_mod<let N: u32>(
let mut divisor_u60: U60Repr<N, 2> = U60Repr::from(divisor);
let b = divisor_u60;

if !remainder_u60.gte(divisor_u60) {
let numerator_msb = remainder_u60.get_msb();
let divisor_msb = divisor_u60.get_msb();
if divisor_msb > numerator_msb {
([0; N], numerator)
} else {
let mut bit_difference = remainder_u60.get_msb() - divisor_u60.get_msb();
let mut bit_difference = numerator_msb - divisor_msb;

let mut accumulator_u60: U60Repr<N, 2> = U60Repr::one();
divisor_u60 = divisor_u60.shl(bit_difference);
Expand Down

0 comments on commit ecb9dec

Please sign in to comment.