-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(comptime): Implement to_be_bits and to_le_bits in the interpreter (
#7008) Co-authored-by: jfecher <[email protected]>
- Loading branch information
Showing
7 changed files
with
61 additions
and
7 deletions.
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
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,7 @@ | ||
[package] | ||
name = "global_eval" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.27.0" | ||
|
||
[dependencies] |
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,20 @@ | ||
use std::uint128::U128; | ||
|
||
// These definitions require `to_be_bits` and `to_le_bits` to be supported at comptime. | ||
global BITS_BE_13: [u1; 4] = (13 as Field).to_be_bits(); | ||
global BITS_LE_13: [u1; 4] = (13 as Field).to_le_bits(); | ||
|
||
// Examples from #6691 which use the above behind the scenes. | ||
global POW64_A: Field = 2.pow_32(64); | ||
global POW64_B: Field = (U128::one() << 64).to_integer(); | ||
|
||
#[test] | ||
fn test_be_and_le_bits() { | ||
assert_eq(BITS_BE_13, [1,1,0,1]); | ||
assert_eq(BITS_LE_13, [1,0,1,1]); | ||
} | ||
|
||
#[test] | ||
fn test_pow64() { | ||
assert_eq(POW64_A, POW64_B); | ||
} |