Skip to content

Instantly share code, notes, and snippets.

@TheBlackPlague
Created September 18, 2021 15:58
Show Gist options
  • Save TheBlackPlague/0de279dc912774488e83c022af6e63d0 to your computer and use it in GitHub Desktop.
Save TheBlackPlague/0de279dc912774488e83c022af6e63d0 to your computer and use it in GitHub Desktop.
binary = '101111000011010101100000';
bin_len = len(binary)
x = 0;
i = 0
while i < bin_len:
x += int(binary[i]) * 2 ** (bin_len - i - 1)
i = i + 1
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment