Repository navigation
Fix Number.prototype.toPrecision for subnormal values - #5664
Open
Basharkhan7776 wants to merge 1 commit into
Open
Basharkhan7776 wants to merge 1 commit into
Basharkhan7776 wants to merge 1 commit into
Conversation
Test262 conformance changes
Fixed tests (1):Broken tests (1):Tested main commit: |
Basharkhan7776
marked this pull request as draft
November 13, 2026 13:36
Basharkhan7776
marked this pull request as ready for review
November 13, 2026 15:19
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed #5662
Number.prototype.toPrecisionformatted the number with{:.100}and then scanned that string for the first non-zero digit.Number.MIN_VALUE(2^-1074, about4.94e-324) is still zero at 100 decimal places, so the scan never saw a digit and the exponent fell through to101.Number.MIN_VALUE.toPrecision(1)returned"0e+101"instead of"5e-324". The same path was wrong for every finite value whose first significant digit sits past the 100th decimal place, including tiny normals such as1e-101and2 ** -1022. Ordinary values were unaffected.Every finite
f64is a multiple of2^-1074, so 1074 decimal places is the exact fixed-point expansion.to_precisionnow formats with{:.1074}and still rounds through the existingflt_str_to_expandround_to_precisionhelpers.to_precision_subnormalcovers the reported calls (toPrecision(1)andtoPrecision(21)), the negative value, precisions 2, 17, and 100, values past the old 100-place window, andNumber.MAX_VALUE. Existingto_precisiontests still pass.cargo test -p boa_engine --lib builtins::number::tests::to_precision