This commit is contained in:
2026-04-21 11:03:16 +02:00
parent 3f92778516
commit d19b51844a
+10 -10
View File
@@ -189,18 +189,18 @@ fn e(byte1: u8, byte2: u8) -> [u8; 8] {
/// BP. /// BP.
/// input bits numbered: 01234567 (bit 0 LSB), /// input bits numbered: 01234567 (bit 0 LSB),
/// output: 37612405. /// output: 50421673.
fn bp(x: u8) -> u8 { fn bp(x: u8) -> u8 {
let bit = |pos: u8| -> u8 { (x >> pos) & 1 }; let bit = |pos: u8| -> u8 { (x >> pos) & 1 };
(bit(3) << 7) (bit(5) << 7)
| (bit(7) << 6) | (bit(0) << 6)
| (bit(6) << 5) | (bit(4) << 5)
| (bit(1) << 4) | (bit(2) << 4)
| (bit(2) << 3) | (bit(1) << 3)
| (bit(4) << 2) | (bit(6) << 2)
| (bit(0) << 1) | (bit(7) << 1)
| bit(5) | bit(3)
} }
#[cfg(test)] #[cfg(test)]
@@ -271,7 +271,7 @@ mod tests {
fn test_bp() { fn test_bp() {
let x = 0b10110010; let x = 0b10110010;
let result = bp(x); let result = bp(x);
assert_eq!(result, 0b01010101); assert_eq!(result, 0b10101010);
} }
#[test] #[test]