Skip to content

math.big: fix the order of calculations in mod_pow()#24935

Merged
spytheman merged 1 commit into
vlang:masterfrom
tankf33der:mod_pow_fix
Jul 20, 2025
Merged

math.big: fix the order of calculations in mod_pow()#24935
spytheman merged 1 commit into
vlang:masterfrom
tankf33der:mod_pow_fix

Conversation

@tankf33der

@tankf33der tankf33der commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

By changing the order of executing multiplication and taking modulo, the result is equally correct, but the numbers always remain within the modulus bounds.
As a result, the function works faster:

2.325ms -> 61.188us

Also function passed the tests against gmplib.

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-23404

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman merged commit 987c211 into vlang:master Jul 20, 2025
76 checks passed
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