Conversation
🛡️ Immunefi PR ReviewsWe noticed that your project isn't set up for automatic code reviews. If you'd like this PR reviewed by the Immunefi team, you can request it manually using the link below: Once submitted, we'll take care of assigning a reviewer and follow up here. |
79e493e to
e9cdb62
Compare
77073ee to
336decb
Compare
For functions that converge via Newton-Raphson over a fixed factor-of-2 range, the initial seed determines how many iterations are needed. By choosing seeds that balance worst-case over/underestimate across the range, one iteration can be dropped while maintaining sufficient precision for the floor/ceil correction. 512Math._sqrt: replace 2^127 with √(2^255) ≈ √2·2^127 (geometric mean of [2^127, 2^128)). Balances ε to ±0.41/0.29, giving >128 bits after 6 Babylonian steps instead of 7. Move floor correction into _sqrt so sqrtUp never sees z=2^128 (prevents mul overflow). 512Math._cbrt: replace 2^84 with ⌊∛(3·2^251)⌋ (balancing point for [2^83.67, 2^84.67)). Balances ε to ±0.44/0.28, giving >85 bits after 6 Newton-Raphson steps. Replace conditional 7th iteration + floor with branchless floor correction. Cbrt._cbrt: multiply the clz-based seed by 233/256 ≈ ∛(3/4), balancing each octave triplet. Drop from 7 to 6 Newton-Raphson iterations. Sqrt._sqrt: the alternating-endpoint seed already equalizes ε₁=0.0607 via the AM-GM identity. Simply drop the 7th Babylonian step and move the floor correction into _sqrt. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
336decb to
fdd626c
Compare
e1Ru1o
approved these changes
Apr 7, 2026
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.
No description provided.