Skip to content

Instantly share code, notes, and snippets.

@fmayer
Created October 12, 2012 16:00
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 fmayer/3879933 to your computer and use it in GitHub Desktop.
Save fmayer/3879933 to your computer and use it in GitHub Desktop.
def bin(x):
s = ""
while True:
s += str(x & 1)
x >>= 1
if not x:
break
return '0b' + s[::-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment