Add ceiling versions of the non-ring operations in 512Math#466
Merged
Add ceiling versions of the non-ring operations in 512Math#466
Conversation
I have added a comment to the source file explaining why the implementation is actually safe with the `clz` version of `Sqrt._sqrt`. Anybody who touches this file should be cautious to ensure that this edge case remains covered. This reverts commit 792d53d.
Add fuzz tests for all ceiling division variants: - divUp(uint512, uint256) and divUp(uint512, uint512) - odivUp/idivUp with uint256 and uint512 divisors Add fuzz test for osqrtUp covering: - Zero case (r=0 implies x=0) - Overflow case (r=2^256, verify (r-1)² < x) - Normal case (verify r² >= x and (r-1)² < x) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🛡️ 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. |
This reverts commit 4b435e6.
e1Ru1o
approved these changes
Jan 6, 2026
This saves some contract size and some gas. It also lets us avoid the 512x245->768 multiplications later on in that function
e1Ru1o
approved these changes
Jan 8, 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.
Also add shifting operations and adopt the updated
clzversion ofsqrtfrom Vectorized/solady#1503