Skip to content

Commit

Permalink
Fix uint256_mul_div_mod bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 committed Jul 10, 2023
1 parent 44dae41 commit 05c3b02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

#### Upcoming Changes

* fix: fix `UINT256_MUL_DIV_MOD` hint [#1320](https://github.com/lambdaclass/cairo-vm/pull/1320)

* feat: add dependency installation script `install.sh` [#1298](https://github.com/lambdaclass/cairo-vm/pull/1298)

* fix: specify resolver version 2 in the virtual workspace's manifest [#1311](https://github.com/lambdaclass/cairo-vm/pull/1311)
Expand Down
8 changes: 4 additions & 4 deletions vm/src/hint_processor/builtin_hint_processor/uint256_utils.rs
Expand Up @@ -431,10 +431,10 @@ pub fn uint256_mul_div_mod(
let div_high = div_high.as_ref();

// Main Logic
let a = a_high.shl(128_usize) + a_low;
let b = b_high.shl(128_usize) + b_low;
let div = div_high.shl(128_usize) + div_low;
let (quotient, remainder) = (a.to_biguint() * b.to_biguint()).div_mod_floor(&div.to_biguint());
let a = a_high.to_biguint().shl(128_usize) + a_low.to_biguint();
let b = b_high.to_biguint().shl(128_usize) + b_low.to_biguint();
let div = div_high.to_biguint().shl(128_usize) + div_low.to_biguint();
let (quotient, remainder) = (a * b).div_mod_floor(&div);

// ids.quotient_low.low
vm.insert_value(
Expand Down

0 comments on commit 05c3b02

Please sign in to comment.