Skip to content

Commit

Permalink
rounding fix for input numbers less than 1000
Browse files Browse the repository at this point in the history
n < 1000 was skipping While block and showing many decimals, if input had many decimals.
  • Loading branch information
Gordon Wall committed Jul 8, 2021
1 parent c7f9fb4 commit fef20ac
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions millify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('.')
Expand Down

0 comments on commit fef20ac

Please sign in to comment.