Created
January 14, 2020 04:03
-
-
Save dedeco/6ea5269419fda4e4af5613f23bf617b9 to your computer and use it in GitHub Desktop.
Como computar o bit de paridade?
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 parity(x): | |
result = 0 | |
while x: | |
result ^= x & 1 | |
x >>= 1 | |
return result | |
if __name__ == "__main__": | |
print(parity(42)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment