fix: preserve BigInt precision above Number.MAX_SAFE_INTEGER - #355
Conversation
Adds the proposal, design, specs, and tasks for fixing BigInt precision loss and unit boundary misdetection in filesize().
Adds a dedicated BigInt branch in filesize() that computes the unit exponent and value using bigint arithmetic, preserving precision above 2^53 and detecting unit boundaries accurately. The BigInt branch rejoins the common output path after computing value and exponent. Fixes #354
Audit Results — fix-bigint-precisionGoal fulfillment: All 4 goals met.
Spec compliance: The implementation matches the spec delta requirements. BigInt exponent detection uses Task completion: All 11 tasks in Quality check:
Note on the original issue: The issue listed |
Summary
Fixes BigInt precision loss in
filesize(). When abigintaboveNumber.MAX_SAFE_INTEGER(2^53 - 1) was passed,Number(arg)coercion silently dropped precision —filesize(BigInt(2 ** 53 + 1))returned the same result asfilesize(BigInt(2 ** 53)). Adds a dedicated BigInt branch that computes the unit exponent and value usingbigintarithmetic, preserving precision and detecting unit boundaries accurately.Type of Change
Related Issues
Closes #354
Testing
2^53vs2^53+1produce distinct results)npm testpasses: 267 tests, 0 failuresnpm run coverage: 100% statement, branch, function, and line coveragenpm run buildsucceedsChecklist
npm testpassesnpm run buildsucceedsScreenshots (if applicable)
N/A