BP fix 2
This commit is contained in:
+10
-10
@@ -189,18 +189,18 @@ fn e(byte1: u8, byte2: u8) -> [u8; 8] {
|
||||
|
||||
/// BP.
|
||||
/// input bits numbered: 01234567 (bit 0 LSB),
|
||||
/// output: 37612405.
|
||||
/// output: 50421673.
|
||||
fn bp(x: u8) -> u8 {
|
||||
let bit = |pos: u8| -> u8 { (x >> pos) & 1 };
|
||||
|
||||
(bit(3) << 7)
|
||||
| (bit(7) << 6)
|
||||
| (bit(6) << 5)
|
||||
| (bit(1) << 4)
|
||||
| (bit(2) << 3)
|
||||
| (bit(4) << 2)
|
||||
| (bit(0) << 1)
|
||||
| bit(5)
|
||||
(bit(5) << 7)
|
||||
| (bit(0) << 6)
|
||||
| (bit(4) << 5)
|
||||
| (bit(2) << 4)
|
||||
| (bit(1) << 3)
|
||||
| (bit(6) << 2)
|
||||
| (bit(7) << 1)
|
||||
| bit(3)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -271,7 +271,7 @@ mod tests {
|
||||
fn test_bp() {
|
||||
let x = 0b10110010;
|
||||
let result = bp(x);
|
||||
assert_eq!(result, 0b01010101);
|
||||
assert_eq!(result, 0b10101010);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user