Skip to content

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

Description

@SashaMIT

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions