Swiftpack.co - Package - std-swift/ModularArithmetic

ModularArithmetic

Modular arithmetic in Swift

Importing

import ModularArithmetic
dependencies: [
	.package(url: "https://github.com/std-swift/ModularArithmetic.git",
	         from: "1.0.0")
],
targets: [
	.target(
		name: "",
		dependencies: [
			"ModularArithmetic"
		]),
]

Using

ModularOperations

Declares modular arithmetic operations:

func modulo(_ modulo: Self) -> Self
func adding(_ other: Self, modulo: Self) -> Self
func subtracting(_ other: Self, modulo: Self) -> Self
func multiplying(_ other: Self, modulo: Self) -> Self
func exponentiating(by exponent: Self, modulo: Self) -> Self
func inverse(modulo: Self) -> Self?

Default implementations:

  • modulo -> BinaryInteger, UnsignedInteger
  • adding -> FixedWidthInteger
  • subtracting -> FixedWidthInteger
  • multiplying -> FixedWidthInteger
  • exponentiating -> BinaryInteger
  • inverse -> BinaryInteger

(U)Int(8|16|32|64) all conform.

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 1