intcomma returns scientific notation for large floats

Open Beginner friendly
#431 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@TheNetherWatcher is already working on this.

Since Oct 2, 2026.

  • #432 by @TheNetherWatcher — open
  • #449 by @Vinayak19112003 — closed without merging
  • #484 by @mayur-dhavan — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
tooling

Research direction

Start at the intcomma() entry point and reproduce the reported large and small float examples. Trace the float-formatting path and add coverage showing that values such as 1e16 and 0.00001 use decimal notation with grouping, matching the expected outputs in the issue.

Written by the indexing model from the issue text.

Description

intcomma() returns scientific notation for floats of 1e16 and above, with no commas added:

>>> humanize.intcomma(1e15)
'1,000,000,000,000,000.0'
>>> humanize.intcomma(1e16)
'1e+16'
>>> humanize.intcomma(1.5e20)
'1.5e+20'

I expected '10,000,000,000,000,000.0' and '150,000,000,000,000,000,000.0'. Passing ndigits works around it (intcomma(1e16, 0) gives '10,000,000,000,000,000').

This happens because f"{value:,}" on a float uses the same formatting as repr(), and that switches to an exponent at 1e16. Small floats hit the same thing, e.g. intcomma(0.00001) returns '1e-05'.

Dominant language
Python
Stars
768
Forks
243
Avg merge
4d 12h
Merged PRs (30d)
19

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-humanize/humanize

All issues in python-humanize/humanize

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.