Skip to content

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

Closed
underwoo wants to merge 3 commits into
mainfrom
fix/issue-1-scientific-notation
Closed

fix: prevent scientific notation for exact powers of 10#8
underwoo wants to merge 3 commits into
mainfrom
fix/issue-1-scientific-notation

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: 47/47 passed
  • mypy: clean
  • pylint: clean

Closes #1

underwoo and others added 3 commits June 21, 2026 21:00
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…c-notation

# Conflicts:
#	tests/test_fsize_init.py
…c-notation

# Conflicts:
#	tests/test_fsize_init.py
@underwoo underwoo closed this Jun 22, 2026
@underwoo underwoo deleted the fix/issue-1-scientific-notation branch June 22, 2026 03:12
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