Skip to content

Commit 8141d9b

Browse files
alonh5kariy
authored andcommitted
Fix uint256_mul_div_mod bug. (lambdaclass#1320)
1 parent 6e9afa2 commit 8141d9b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#### Upcoming Changes
44

5+
* fix: fix `UINT256_MUL_DIV_MOD` hint [#1320](https://github.com/lambdaclass/cairo-vm/pull/1320)
6+
57
* feat: add dependency installation script `install.sh` [#1298](https://github.com/lambdaclass/cairo-vm/pull/1298)
68

79
* fix: specify resolver version 2 in the virtual workspace's manifest [#1311](https://github.com/lambdaclass/cairo-vm/pull/1311)

vm/src/hint_processor/builtin_hint_processor/uint256_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,10 @@ pub fn uint256_mul_div_mod(
431431
let div_high = div_high.as_ref();
432432

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

439439
// ids.quotient_low.low
440440
vm.insert_value(

0 commit comments

Comments
 (0)