baseconvert¶
-
decida.
baseconvert
(base_from, base_to, number, digits=None)¶ synopsis:
Convert number in one base to another.
The input number to be converted by baseconvert is the number’s string representation in base_from. The result is the number’s string representation in base_to.
arguments:
base_from (int)
number is represented in this basebase_to (int)
output is to be represented in this basenumber (str)
input number represented in base base_fromdigits (int, default=None)
if specified, and output string is shorter than digits, fill with zeros until output string is digits longresult:
return string representation of number in base base_toexamples:
>>> import decida >>> decida.baseconvert(16, 10, "1242") '74562'
>>> import decida >>> decida.baseconvert(10, 16, "113", 4) '0071'