Repository navigation
The type of a huge integer literal no longer costs a division by a power of ten as large as it - #432
Closed
enumeratio wants to merge 1 commit into
Closed
enumeratio wants to merge 1 commit into
enumeratio wants to merge 1 commit into
Conversation
… past the double range; count the digits of a huge bigint from a log10 estimate with one exact check; shift only the numerator in bigRatioToFloat. Fix cortex-js#431
Member
|
Landed on main as de19cf1 with your commit's content, credited as co-author. Two small edits on the way in: the CHANGELOG entry moved to a new [Unreleased] section (0.153.0 had shipped), and the four rationalAsFloat tie tests now use 2^200 denominators so the quotients stay finite (near 2^953; at 2^1053 the expected value was Infinity and the tests passed without the sticky bit). Thanks for the fix and the careful error analysis. |
arnog
added a commit
that referenced
this pull request
Oct 14, 2026
… large integers (merge PR #432) Co-authored-by: enumeratio <enumeratio@users.noreply.github.com>
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.
Fix #431.
.typeof an integer literal past the double range:literalEnclosureTypenow returns no enclosure as soon as the literal's double value is±Infinity, before any bignum work. Both bounds would have had to be finite doubles, so the type is unchanged (integer<1..>,integer<..-1>).bigintDigitspast thepow10cache limit (100 000 digits): it now estimateslog10(n)from the top hex digits and the hex length, and makes one exactn >= 10^kcomparison only when the estimate is within its rounding margin of an integer. Below the limit nothing changes.bigRatioToFloat, which computes.re: it reads bit lengths from the hex form, and when the numerator is wider it shifts only the numerator. The quotient and the sticky bit (which decides rounding) are the same as before.ce.number(7n * 10n ** BigInt(d) + 12345n).type, per new literal (ms, median of 7):toString(16)New tests check:
bigintDigitsagainsttoString().lengtharound10^kon both sides of the cache limit, and for random values;rationalAsFloatat exact ties and just above them, with a wide numerator;