Skip to content

Instantly share code, notes, and snippets.

@alexandre
Created July 11, 2014 03:18
Show Gist options
  • Save alexandre/b1ffc07f2d90e0f6e99d to your computer and use it in GitHub Desktop.
Save alexandre/b1ffc07f2d90e0f6e99d to your computer and use it in GitHub Desktop.
converter um valor em binário para decimal...
def bin2dec(num):
'''
Exemplo simples para converter um binário para decimal
'''
return sum([int(bit)*2**position for position,bit in enumerate(str(num)[::-1])])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment