Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrapper: Add modular arithmetic functions to ArbitraryPrecisionInteger #284

Conversation

simonjbeaumont
Copy link
Contributor

Motivation

A number of higher level schemes we'd like to be able to express make use of modular arithmetic with big integers.

Modifications

This PR adds more internal (package-visible) functions to ArbitraryPrecisionInteger:

  • ArbitraryPrecisionInteger.modulo(_ mod: ArbitraryPrecisionInteger, nonNegative: Bool = false) throws -> ArbitraryPrecisionInteger
  • ArbitraryPrecisionInteger.inverse(modulo mod: ArbitraryPrecisionInteger) throws -> ArbitraryPrecisionInteger
  • ArbitraryPrecisionInteger.add(_ rhs: ArbitraryPrecisionInteger, modulo modulus: ArbitraryPrecisionInteger? = nil) throws -> ArbitraryPrecisionInteger
  • ArbitraryPrecisionInteger.sub(_ rhs: ArbitraryPrecisionInteger, modulo modulus: ArbitraryPrecisionInteger? = nil) throws -> ArbitraryPrecisionInteger
  • ArbitraryPrecisionInteger.mul(_ rhs: ArbitraryPrecisionInteger, modulo modulus: ArbitraryPrecisionInteger? = nil) throws -> ArbitraryPrecisionInteger

Result

No API change; just more internal functionality we can use.

@Lukasa Lukasa added the semver/patch No public API change. label Oct 17, 2024
@Lukasa Lukasa enabled auto-merge (squash) October 17, 2024 12:22
@Lukasa Lukasa merged commit 4324b40 into apple:main Oct 17, 2024
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants