Created
December 26, 2019 07:39
-
-
Save grafi-tt/b194a04108e6ab36340ea0a7b196d742 to your computer and use it in GitHub Desktop.
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
fn byte_to_ascii(byte: u8) -> [u8; 8] { | |
let diag = 0b10000000_01000000_00100000_00010000_00001000_00000100_00000010_00000001u64; | |
let mut byte_ascii = byte as u64 * diag; | |
byte_ascii &= 0x8080808080808080; | |
byte_ascii >>= 7; | |
byte_ascii += 0x3030303030303030; | |
byte_ascii.to_le_bytes() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment