Skip to content

Instantly share code, notes, and snippets.

@dedeco
Created January 14, 2020 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dedeco/6ea5269419fda4e4af5613f23bf617b9 to your computer and use it in GitHub Desktop.
Save dedeco/6ea5269419fda4e4af5613f23bf617b9 to your computer and use it in GitHub Desktop.
Como computar o bit de paridade?
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