Created
April 17, 2016 02:47
-
-
Save CreateRemoteThread/e8a9ee6a542bc564c2b3da18096baf0c to your computer and use it in GitHub Desktop.
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
import string | |
digs = string.digits + string.letters | |
def int2base(x, base): | |
if x < 0: sign = -1 | |
elif x == 0: return digs[0] | |
else: sign = 1 | |
x *= sign | |
digits = [] | |
while x: | |
digits.append(digs[x % base]) | |
x /= base | |
if sign < 0: | |
digits.append('-') | |
digits.reverse() | |
return ''.join(digits) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment