Fix to_base for 0.

Further proof that nobody is using this code.
This commit is contained in:
voussoir 2020-12-05 20:00:27 -08:00
parent f8c0d46c5e
commit bf2865077a

View file

@ -68,6 +68,8 @@ def to_base(number, base, decimal_places=10, alphabet=None):
result = '' result = ''
whole_portion = int(number) whole_portion = int(number)
float_portion = number - whole_portion float_portion = number - whole_portion
if whole_portion == 0:
result = alphabet[0]
while whole_portion > 0: while whole_portion > 0:
(whole_portion, remainder) = divmod(whole_portion, base) (whole_portion, remainder) = divmod(whole_portion, base)
result = alphabet[remainder] + result result = alphabet[remainder] + result