From fef20ac6119c52152163801b2fd1367529b45f43 Mon Sep 17 00:00:00 2001 From: Gordon Wall Date: Thu, 8 Jul 2021 10:26:40 -0400 Subject: [PATCH] rounding fix for input numbers less than 1000 n < 1000 was skipping While block and showing many decimals, if input had many decimals. --- millify/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/millify/__init__.py b/millify/__init__.py index f9467b6..5c08227 100644 --- a/millify/__init__.py +++ b/millify/__init__.py @@ -17,6 +17,8 @@ def millify(n, precision=0, drop_nulls=True, prefixes=[]): while abs(n) >= 1000: millidx += 1 n = round(n / 1000.0, precision) + if n < 1000: + round(n, precision) result = '{}'.format(n) if drop_nulls: result = result.rstrip('0').rstrip('.')