Skip to content

fix(intword): correct decillion-to-googol gap and carry-over rounding - #364

Open
mmaxjr wants to merge 1 commit into
python-humanize:mainfrom
mmaxjr:fix/intword-decillion-googol-gap
Open

fix(intword): correct decillion-to-googol gap and carry-over rounding#364
mmaxjr wants to merge 1 commit into
python-humanize:mainfrom
mmaxjr:fix/intword-decillion-googol-gap

Conversation

@mmaxjr

@mmaxjr mmaxjr commented Jul 30, 2026

Copy link
Copy Markdown

Fixes #356

Problem

intword()'s powers table jumps straight from decillion (1033) to googol (10100), with no unit in between. Any value in [1036, 10100) got chopped into a decillion count that grows arbitrarily large:

>>> intword(10**50)
'100000000000000000.0 decillion'
>>> intword(10**100 - 10**93)
'9999999000000000610151082626636586748864734715312950532670947852288.0 decillion'

`powers` jumps from decillion (10**33) directly to googol (10**100),
so any value in [10**36, 10**100) was chopped into a decillion count
that grew arbitrarily large (e.g. 10**50 -> "100000000000000000.0
decillion"), and values that should round up into googol (e.g.
10**100 - 10**93) never carried over.

Only advance to the next named unit when the value actually rounds
up to it; otherwise there is no unit for that magnitude, so fall
back to the plain integer, mirroring how intword() already falls
back to a plain value below the smallest unit.

Fixes python-humanize#356

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

intword: values between 10^36 and a googol format as huge decillion counts, and rounding to the next unit does not carry

1 participant