Created
July 11, 2014 03:18
-
-
Save alexandre/b1ffc07f2d90e0f6e99d to your computer and use it in GitHub Desktop.
converter um valor em binário para decimal...
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 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