Revision: 11932
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 24, 2009 06:14 by nategood
Initial Code
def bs(s): return str(s) if s<=1 else bs(s>>1) + str(s&1)
Initial URL
Initial Description
Couldn't find a built in way to do this. Neatly prints an int as bit string. Recursive so not the most efficient but switching it to iterative would be cake if performance is that big an issue. Warning doesn't support negative numbers... simple enough to convert to one or two's complement.
Initial Title
Convert from int to bit string
Initial Tags
Initial Language
Python