From bf2865077afd1c9f9b43171c03042f98756dc5fd Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 5 Dec 2020 20:00:27 -0800 Subject: [PATCH] Fix to_base for 0. Further proof that nobody is using this code. --- voussoirkit/basenumber.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/voussoirkit/basenumber.py b/voussoirkit/basenumber.py index 5b5ed13..09827ab 100644 --- a/voussoirkit/basenumber.py +++ b/voussoirkit/basenumber.py @@ -68,6 +68,8 @@ def to_base(number, base, decimal_places=10, alphabet=None): result = '' whole_portion = int(number) float_portion = number - whole_portion + if whole_portion == 0: + result = alphabet[0] while whole_portion > 0: (whole_portion, remainder) = divmod(whole_portion, base) result = alphabet[remainder] + result