Created
February 4, 2013 21:52
-
-
Save scragg0x/4710045 to your computer and use it in GitHub Desktop.
Python rotate bits to the right
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
def rotr(x, n=1, bits=8): | |
while True: | |
x = ((x & 1) << bits-1 | x >> 1) | |
n -= 1 | |
if not n: | |
break | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment