/dvbt/trunk/debug/subblocks/csee_old/intxxbin.py
Python | 9 lines | 8 code | 0 blank | 1 comment | 0 complexity | f2fd75243840037d52be2effeca2990f MD5 | raw file
1def int2bin(n): 2 '''convert denary integer n to binary string bStr''' 3 bStr = '' 4 if n < 0: raise ValueError, "must be positive" 5 if n == 0: return '0' 6 while n > 0: 7 bStr = str(n % 2) + bStr 8 n = n >> 1 9 return bStr