Repository navigation
Build a whole power by a loop over the exponent's bits - #2363
Merged
Merged
Conversation
The whole power was a recursion on the half of the exponent, one frame for each of its bits, and a power of -1, i or -i is never too large to build. So (-1)^(2^20000) took 20000 frames and overflowed the stack of a thread-pool thread, 1.5 MB on Linux -- which ends the process rather than throwing. limitcheck died that way at SEED=28, evaluating a sample point. A loop from the exponent's top bit down makes the same multiplications in the same order: the recursion's half truncates toward zero, so a negative exponent is the bits of its magnitude, each multiplying by 1 / num. Exact and decimal powers, real and complex, come out digit for digit as before. limitcheck at DEPTH=3, SEED=28 now finishes its 600 expressions. No issue was filed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2363 +/- ##
=======================================
Coverage 86.78% 86.78%
=======================================
Files 312 312
Lines 68825 68825
Branches 20053 20053
=======================================
+ Hits 59732 59733 +1
Misses 4909 4909
+ Partials 4184 4183 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
(-1)^(2^20000)overflowed the stack of a thread-pool thread, which is 1.5 MB on Linux. A stack overflow ends the process rather than throwing. limitcheck died that way atDEPTH=3,SEED=28, while evaluating a sample point.The whole power was built by a recursion on half the exponent, one frame per bit.
IsTooLargeToBuildrightly never stops a power of -1, i or -i, since those do not grow, so nothing bounded the depth.It is now a loop from the exponent's top bit down. The loop makes the same multiplications in the same order. The recursion's half truncates toward zero, so a negative exponent is the bits of its magnitude, each one multiplying by
1 / num. Exact and decimal powers, real and complex, come out digit for digit as before. The test pins four of them, beside the unit powers on a 256 KB thread, where master ends the test host with "Stack overflow".limitcheck at
SEED=28now finishes its 600 expressions. Suite, AOT and the harnesses are green locally. No issue was filed.🤖 Generated with Claude Code