-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a cairo program that uses
u512_safe_div_mod_by_u256
libfunc + r…
…emove it from not yet implemented list (#364) * Add test program * Add test case * Remove libfunc from list
- Loading branch information
Showing
3 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use integer::{u512, u512_safe_div_rem_by_u256}; | ||
|
||
fn main() { | ||
let zero = u512 { limb0: 0, limb1: 0, limb2: 0, limb3: 0 }; | ||
let one = u512 { limb0: 1, limb1: 0, limb2: 0, limb3: 0 }; | ||
|
||
let (q, r) = u512_safe_div_rem_by_u256(zero, integer::u256_as_non_zero(1)); | ||
assert(q == zero, '0 / 1 != 0'); | ||
assert(r == 0, '0 % 1 != 0'); | ||
|
||
let (q, r) = u512_safe_div_rem_by_u256(one, integer::u256_as_non_zero(1)); | ||
assert(q == one, '1 / 1 != 1'); | ||
assert(r == 0, '1 % 1 != 0'); | ||
|
||
let two = u512 {limb0: 0, limb1: 0, limb2: 0, limb3: 2}; | ||
let (q, r) = u512_safe_div_rem_by_u256(two, integer::u256_as_non_zero(1)); | ||
assert(q == two, '2/1 != 2'); | ||
assert(r == 0, '2/1 != 0'); | ||
|
||
return (); | ||
} |