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 base
base_to (int)
output is to be represented in this base
number (str)
input number represented in base base_from
digits (int, default=None)
if specified, and output string is shorter than digits, fill with zeros until output string is digits long
result:
return string representation of number in base base_to
examples:
>>> import decida >>> decida.baseconvert(16, 10, "1242") '74562'
>>> import decida >>> decida.baseconvert(10, 16, "113", 4) '0071'
>>> import decida >>> decida.baseconvert(10, 16, "113.234") '71.3be'