Update XCode build schemes.
Deleted and re-iniitalized schemes after running into the issue here: https://stackoverflow.com/questions/4023240/is-there-any-way-to-solve-com-apple-product-type-framework-issue
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
ModulusOperandi
Declarative, multi-algorithm modular arithmetic for Swift Integers and Floating-Point types.
Modular arithmetic algorithms come in variants that use either Euclidean, truncating, or flooring division. Furthermore, Swift’s built-in
%operator — while used as a modulus in some languages — is strictly used as a remainder operator.These nuances can lead modular arithmetic code that’s ambiguous in both intent and correctness — which is what
ModulusOperandiattempts to solve.Features
BinaryIntegerandFloatingPointInteger.Installation
Xcode Projects
Select
File->Swift Packages->Add Package Dependencyand enterhttps://github.com/CypherPoet/ModulusOperandi.Swift Package Manager Projects
You can add
ModulusOperandias a dependency in yourPackage.swiftfile:Then simply
import ModulusOperandiwherever you’d like to use it.Usage
After importing
ModulusOperandiin a file, types that conform toBinaryIntegerandFloatingPointIntegerwill be extended with amodulusfunction.This function treats its value as the
dividendand takes adivisorof the same type. It also takes an optionalmodeargument to choose between Euclidean, Truncating, or Flooring Modular Arithmetic.By default, the
modewill be EuclideanCommand Line Tool
ModulusOperandialso ships with a command line tool that lets you perform calculations directly from the command line.To install it, clone the project and run
make:The command line tool will be installed as
modulo, and runningmodulo --helpwill present some helpful usage instructions:See Help Menu
Negative Numbers
Disambiguating negative numbers from argument flags is a notorious challenge for Command Line interfaces. Currently, support for this in Swift’s Argument Parser appears to be an ongoing area of development. In the meantime, though, the
modulocommand can take negative-number arguments via some clever escape syntax.Simply prefix any negative number with
\(including the space). Like so:-5 mod 4:-5 mod -4:5 mod -4:Contributing
Contributions to
ModulusOperandiare most welcome. Check out some of the issue templates for more info.Developing
Requirements
Generating Documentation
Documentation is generated by Jazzy. Installation instructions can be found here, and as soon as you have it set up, docs can be generated simply by running
jazzyfrom the command line.📝 Note that this will only generate the
docsfolder for you to view locally. This folder is being ignored bygit, as an action exists to automatically generate docs and serve them on the project’sgh-pagesbranch.License
ModulusOperandiis available under the MIT license. See the LICENSE file for more info.