Skip to content

fix: prevent scientific notation leak in precision output - #419

Merged
avoidwork merged 5 commits into
masterfrom
fix/fix-precision-scientific-notation
Nov 17, 2026
Merged

avoidwork merged 5 commits into
masterfrom
fix/fix-precision-scientific-notation

Conversation

@avoidwork

@avoidwork avoidwork commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes the precision option leaking scientific notation (e+/e-) into output for values at or above the unit ceiling (exponent 8, e.g. YB/YiB). applyNumberFormatting now expands scientific notation for string precision results, so values like 10^30 render as 1000000 YB instead of 1.00e+6 YB.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature / enhancement
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Build / dependency / tooling change
  • Test additions or updates
  • Other

Related Issues

Closes #418

Testing

  • Added regression tests in tests/unit/filesize.test.js covering the three reproduction cases.
  • npm test passes: 284 tests, 100% line/branch/function coverage.
  • npm run build succeeds.
  • Verified existing behavior for locale, separator, padding, negative values, and bigint precision is preserved.

Checklist

  • npm test passes
  • npm run build succeeds
  • 100% test coverage maintained
  • No hardcoded secrets or credentials introduced
  • Zero external dependencies added
  • ES Modules only (no CommonJS in src/)
  • JSDoc comments added/updated
  • CHANGELOG.md updated (if applicable)

Screenshots (if applicable)

N/A

Adds proposal, spec delta, design, and tasks for fixing the precision
option leaking scientific notation at the exponent ceiling.
@avoidwork avoidwork self-assigned this Nov 16, 2026
Expand scientific notation for string precision results in
applyNumberFormatting so values at the exponent ceiling (e.g. YB/YiB)
render as plain decimals instead of '1.00e+6'. Adds regression tests.
Apply oxfmt formatting and rebuild dist bundles.
Archive the OpenSpec change and sync the number-formatting spec.
@avoidwork avoidwork changed the title fix: precision output leaks scientific notation at exponent ceiling fix: prevent scientific notation leak in precision output Nov 17, 2026
@avoidwork

Copy link
Copy Markdown
Owner Author

Audit Results

Goal fulfillment: All goals met.

  • Fixed applyNumberFormatting in src/helpers.js to expand scientific notation for string precision results.
  • All three reproduction cases now produce clean decimal output with no e/E:
    • filesize(10n**30n, {precision: 3}) → 1000000 YB
    • filesize(1024n**8n*1000n, {precision: 2, standard: "iec"}) → 1000 YiB
    • filesize(10n**27n, {precision: 3}) → 1000 YB

Spec compliance: The new requirement "Precision output never uses scientific notation" is satisfied by the implementation and covered by regression tests.

Task completion: All tasks in tasks.md are marked complete.

Quality check: No regressions. Full suite passes (284 tests), 100% coverage maintained, lint clean, build succeeds. Existing behavior for locale, separator, padding, negative values, and bigint precision is preserved.

Iterations: spec-audit 1, impl-audit 1 (no errors found).

@avoidwork
avoidwork merged commit 882c646 into master Nov 17, 2026
2 checks passed
@avoidwork
avoidwork deleted the fix/fix-precision-scientific-notation branch November 17, 2026 00:22
@avoidwork avoidwork mentioned this pull request Nov 17, 2026
9 of 15 tasks
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.

fix: precision output leaks scientific notation at exponent ceiling

1 participant