Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

humanize.intcomma(num, ndigits=0) does not behave as expected #24

Closed
CoinSearchr opened this issue Jun 20, 2022 · 2 comments · Fixed by #26
Closed

humanize.intcomma(num, ndigits=0) does not behave as expected #24

CoinSearchr opened this issue Jun 20, 2022 · 2 comments · Fixed by #26
Labels
bug Something isn't working

Comments

@CoinSearchr
Copy link

What did you do?

Run a call like humanize.intcomma(12345.111, ndigits=0).

What did you expect to happen?

I expected the return value to be "12,345".

If ndigits=0, I would expect there to be no digits after the decimal place (i.e., 0 decimal digits).

What actually happened?

The return value is "12,345.111".

Alternative Solution

If it is decided that changing this behavior is completely inappropriate, then it is critical that the documentation be updated to explain:

  • ndigits must be >0
  • If ndigits=0 or ndigits=None, then all digits are kept.

What versions are you using?

  • OS: Ubuntu
  • Python: 3.9
  • Humanize: 4.1.0
@CoinSearchr CoinSearchr changed the title humanize.intcomma with ndigits=0 does not behave as expected humanize.intcomma(num, ndigits=0) does not behave as expected Jun 20, 2022
@hugovk hugovk added the bug Something isn't working label Jun 21, 2022
@hugovk
Copy link
Member

hugovk commented Jun 21, 2022

Thanks, this is a bug, please see PR #26 for a fix.

@CoinSearchr
Copy link
Author

Looks great to me! Good work adding a test case for this! Thanks for doing it so quick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants