Skip to content

Fix intcomma returning scientific notation for large floats - #432

Open
TheNetherWatcher wants to merge 1 commit into
python-humanize:mainfrom
TheNetherWatcher:fix-intcomma-large-floats
Open

TheNetherWatcher wants to merge 1 commit into
python-humanize:mainfrom
TheNetherWatcher:fix-intcomma-large-floats

Conversation

@TheNetherWatcher

@TheNetherWatcher TheNetherWatcher commented Oct 2, 2026 •

Copy link
Copy Markdown

Fixes #431

Changes proposed in this pull request:

  • When a float's string form uses an exponent (1e16 and up, or very small values like 1e-05), format it through Decimal(str(value)) so it comes out as a plain grouped number instead of 1e+16
  • Keep the trailing .0 so the output matches what smaller floats already return (intcomma(1e15) is 1,000,000,000,000,000.0)
  • Ints, floats that don't use an exponent, and the ndigits path are unchanged
  • Added cases to test_intcomma plus one de_DE check in test_i18n

Full test suite (with translation binaries compiled), prek and mypy pass locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

intcomma returns scientific notation for large floats

1 participant