Skip to content

Fix significant figures when metric rounding carries within quetta - #406

Open
agammann wants to merge 1 commit into
python-humanize:mainfrom
agammann:fix-metric-quetta-rounding
Open

agammann wants to merge 1 commit into
python-humanize:mainfrom
agammann:fix-metric-quetta-rounding

Conversation

@agammann

Copy link
Copy Markdown

Rounding within the highest SI prefix currently keeps one extra decimal place: metric(9.999e30, "W") returns 10.00 QW instead of 10.0 QW, and metric(9.999e31, "W") returns 100.0 QW instead of 100 QW.

Allow the existing carry adjustment through exponents 30 and 31. The exponent-32 boundary remains guarded, so rounding to 1000 QW does not advance beyond the prefix table. Add four cases to the existing parameterized test, including a negative value and the upper boundary.

Validation: full pytest suite — 748 passed, 112 skipped; Ruff and Black checks passed on both changed files.

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.

1 participant