KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Python allows easy creation of an integer from a string of a given base via int(str, base). I want to perform the inverse: creation of a string from an integer , i.e. I want some function int2base(num, base) , such that: int(int2base(x, b), b) == x The function name/argument order is unimportant. For any number x and base b that int() will accept. This is an easy function to write: in fact it's easier than describing it in this question. However, I feel like I must be missing something. I know about the functions bin , oct , hex , but I cannot use them for a few reasons: Those functions are not available on older versions of Python, with which I need compatibility with (2.2) I want a general solution that can be called the same way for different bases I want to allow bases other than 2, 8, 16 Related Python elegant inverse function of int(string, base) Integer to base-x system using recursion in python Base 62 conversion in Python How to convert an integer to the shortest url-safe string in Python?
Tags (comma-separated)
Save Edits
Cancel