Skip to content

Add ceiling versions of the non-ring operations in 512Math#466

Merged
duncancmt merged 16 commits intomasterfrom
dcmt/divup
Jan 13, 2026
Merged

Add ceiling versions of the non-ring operations in 512Math#466
duncancmt merged 16 commits intomasterfrom
dcmt/divup

Conversation

@duncancmt
Copy link
Collaborator

Also add shifting operations and adopt the updated clz version of sqrt from Vectorized/solady#1503

duncancmt and others added 14 commits January 5, 2026 15:01
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>
@duncancmt duncancmt requested a review from e1Ru1o January 6, 2026 12:21
@duncancmt duncancmt self-assigned this Jan 6, 2026
@immunefi-magnus
Copy link

🛡️ Immunefi PR Reviews

We 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:

🔗 Send this PR in for review

Once submitted, we'll take care of assigning a reviewer and follow up here.

This saves some contract size and some gas. It also lets us avoid the
512x245->768 multiplications later on in that function
@duncancmt duncancmt merged commit c8ea1d3 into master Jan 13, 2026
3 checks passed
@duncancmt duncancmt deleted the dcmt/divup branch January 13, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants