Skip to content

Commit

Permalink
Merge pull request #26 from hugovk/fix-intcomma-ndigits-0
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jun 21, 2022
2 parents 29d37fb + 03863fe commit 0e6ef5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/humanize/number.py
Expand Up @@ -126,7 +126,7 @@ def intcomma(value: NumberOrString, ndigits: int | None = None) -> str:
ndigits (int, None): Digits of precision for rounding after the decimal point.
Returns:
str: string containing commas every three digits.
str: String containing commas every three digits.
"""
sep = thousands_separator()
try:
Expand All @@ -137,7 +137,7 @@ def intcomma(value: NumberOrString, ndigits: int | None = None) -> str:
except (TypeError, ValueError):
return str(value)

if ndigits:
if ndigits is not None:
orig = "{0:.{1}f}".format(value, ndigits)
else:
orig = str(value)
Expand Down
1 change: 1 addition & 0 deletions tests/test_number.py
Expand Up @@ -54,6 +54,7 @@ def test_ordinal(test_input: str, expected: str) -> None:
([14308.40, 3], "14,308.400"),
([1234.5454545], "1,234.5454545"),
([1234.5454545, None], "1,234.5454545"),
([1234.5454545, 0], "1,235"),
([1234.5454545, 1], "1,234.5"),
([1234.5454545, 2], "1,234.55"),
([1234.5454545, 3], "1,234.545"),
Expand Down

0 comments on commit 0e6ef5a

Please sign in to comment.