Skip to content

Conversation

@Lil-Duckling-22
Copy link

Replace hardcoded magic numbers in AssertLeFindSmallArcs with well-documented named constants. These constants represent mathematical values derived from Cairo's PRIME for range checking optimization. Improves code readability and maintainability by making the mathematical meaning explicit.

Replace hardcoded magic numbers in AssertLeFindSmallArcs with well-documented named constants. These constants represent mathematical values derived from Cairo's PRIME for range checking optimization. Improves code readability and maintainability by making the mathematical meaning explicit.
@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion


crates/cairo-lang-casm/src/hints/mod.rs line 17 at r1 (raw file):

mod test;

/// Mathematical constants for Cairo range checking algorithm.

constants used only once - define in function.

@Lil-Duckling-22 Lil-Duckling-22 requested a review from orizi October 24, 2025 11:17
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @Lil-Duckling-22)


crates/cairo-lang-casm/src/hints/mod.rs line 716 at r2 (raw file):

                let prime_over_3_high = 3544607988759775765608368578435044694_u128;
                // ceil((PRIME / 2) / 2^128) where PRIME = 2^251 + 17*2^192 + 1
                let prime_over_2_high = 5316911983139663648412552867652567041_u128;

prime in this context is known to be that value.

Suggestion:

                // ceil((PRIME / 3) / 2^128)
                let prime_over_3_high = 3544607988759775765608368578435044694_u128;
                // ceil((PRIME / 2) / 2^128)
                let prime_over_2_high = 5316911983139663648412552867652567041_u128;

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.

3 participants