metric() adds a digit when a value rounds into quetta

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

Maintainers usually reply within 1 day

@SashaMIT is already working on this.

Since Oct 1, 2026.

  • #424 by @SashaMIT — open
  • #450 by @Vinayak19112003 — closed without merging
  • #485 by @mayur-dhavan — closed without merging

Assessment

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

Research direction

Start with the metric() entry point and run the reproduction shown in the issue to confirm the quetta boundary behavior. Trace the rounding and prefix selection around 9.996e30 through 9.996e32, then verify that the output matches the four expected examples and preserves the existing 9999 result.

Written by the indexing model from the issue text.

Description

What did you do?
import humanize
print(humanize.metric(9.996e30))
print(humanize.metric(9.996e31))
print(humanize.metric(9.996e32))
print(humanize.metric(9999))
What did you expect to happen?

Three digits, same as 9999, which is already 10.0 k and not 10.00 k.

10.0 Q
100 Q
1.00 x 10³³
10.0 k

9.996e32 has no prefix after quetta, so scientific notation.

What actually happened?
10.00 Q
100.0 Q
1000 Q
10.0 k

The rounding carry stops at exponent 30. 2.596e32 is still 260 QF.

What versions are you using?
  • OS: macOS
  • Python: 3.14
  • Humanize: main
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.