Skip to content

fix: prevent scientific notation for exact powers of 10#12

Merged
underwoo merged 1 commit into
mainfrom
fix-issue1-v2
Jun 22, 2026
Merged

fix: prevent scientific notation for exact powers of 10#12
underwoo merged 1 commit into
mainfrom
fix-issue1-v2

Conversation

@underwoo

Copy link
Copy Markdown
Owner

Fixes #1

format(FSize(n * 1024), "K") now returns "10" instead of "1e+01" for exact powers of 10.

Root cause: math.ceil(math.log10(n)) produces precision equal to the exponent, causing Python's g format to use scientific notation.

Fix: Changed to math.floor(math.log10(n)) + 1 so precision always exceeds the exponent by at least 1.

Verification:

  • pytest: 50/50 passed
  • mypy: clean
  • pylint: clean

Closes #1

@underwoo underwoo merged commit cca3201 into main Jun 22, 2026
9 checks passed
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.

bug: format() produces scientific notation for exact powers of 10

1 participant