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

intword fails to parse numbers >= 1 Googol #134

Open
MajorTanya opened this issue Jul 26, 2023 · 1 comment
Open

intword fails to parse numbers >= 1 Googol #134

MajorTanya opened this issue Jul 26, 2023 · 1 comment

Comments

@MajorTanya
Copy link

What did you do?

I tried to use humanize to convert 10_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000 (1 Googol) to the text output “1 googol” by calling humanize.intword() with the number.

What did you expect to happen?

I expected the text output to be “1 googol” as the documentation for intword claims the library can handle numbers of this size.

What actually happened?

The output was just the number as a string, without any word at all: '10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'

This is also the case for numbers larger than 1 Googol.

What versions are you using?

  • OS: Windows 11 Pro 22H2 22621.1992
  • Python: Python 3.11.4 (also tried 3.10.11, 3.9.13, 3.8.10, and 3.7.9)
  • Humanize: 4.7.0 (4.6.0 for Python 3.7.9)

Please include code that reproduces the issue.

The best reproductions are self-contained scripts with minimal dependencies.

>>> import humanize
# 1 Googol:
>>> GOOGOL = 10_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000
>>> humanize.intword(GOOGOL)
'10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'

# 1 Googol minus 1:
>>> humanize.intword(GOOGOL - 1)
'10000000000000001323945434466030186557813051577054744406252071157760.0 decillion'

# 1000 Googol:
>>> humanize.intword(GOOGOL * 1000)
'10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'

The fact that it doesn't seem to work in any Python versions going all the way back to 3.8 in humanize v4.7.0 (and Python 3.7 with v4.6.0) seems odd to me. It leads me to believe that either I am misunderstanding the documentation, I am using the library wrongly, or something is wrong with how humanize handles a Googol.
If humanize is not supposed to parse a googol to the string “1 googol”, the docs should be updated to reflect that. Currently, they state:

Supports up to decillion (33 digits) and googol (100 digits).
Which I understood meaning “Can parse and display a googol”.

My apologies if the problem turns out to be me misunderstanding/-using.

@hugovk
Copy link
Member

hugovk commented Jul 26, 2023

At first glance, the docstring and constants have been in the codebase for 12 years (0cf1199), but there's no test for googol, so sounds like a bug/regression.

Possibly related to #87 (released in 4.5.0), see also #91.

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

No branches or pull requests

2 participants