Created
July 7, 2018 19:07
-
-
Save JamesTheAwesomeDude/c969276c352ae9bde7786a91e8b66bbe 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
rotr = lambda v,n=1,s=8: ((v>>n)|(v<<(s-n)))&~(~0<<s) | |
rotl = lambda v,n=1,s=8: ((v<<n)|(v>>(s-n)))&~(~0<<s) | |
#rot*(number, number_of_bits_to_shift, size_of_number) | |
assert rotr(0b11110011,3) \ | |
== 0b01111110 | |
assert rotl(0xDEADBEEF,20,32) \ | |
== 0xEEFDEADB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment