-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(old ssa): fix to_be_bits (#1765)
* fix to_le_bits in original ssa * add test
- Loading branch information
Showing
3 changed files
with
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.7.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,24 @@ | ||
use dep::std; | ||
|
||
fn main() { | ||
let field = 1000; | ||
let be_bits = field.to_be_bits(16); | ||
let le_bits = field.to_le_bits(16); | ||
|
||
for i in 0..16 { | ||
let x = be_bits[i]; | ||
let y = le_bits[15-i]; | ||
assert(x == y); | ||
} | ||
|
||
let x = 3; | ||
let be_bits_x = x.to_be_bits(4); | ||
let le_bits_x = x.to_le_bits(4); | ||
|
||
for i in 0..4 { | ||
let be_bit = be_bits_x[i]; | ||
let le_bit = le_bits_x[3-i]; | ||
assert(be_bit == le_bit); | ||
} | ||
|
||
} |
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