ModNum and ModNumC are highly ergonomic modular arithmetic structs intended
for no_std use.
ModNum objects represent a value modulo m. The value and modulo can be of any
primitive integer type. Arithmetic operators include +, - (both unary and binary),
*, /, pow(), and ==. Additional capabilities include computing multiplicative inverses
and solving modular equations.
ModNumC objects likewise represent a value modulo M, where M is a generic constant of the
usize type. Arithmetic operators include +, - (both unary and binary), *, and ==.
This library was originally developed to facilitate bidirectional navigation through fixed-size
arrays at arbitrary starting points. This is facilitated by a double-ended iterator that
traverses the entire ring starting at any desired value. The iterator supports both ModNum and
ModNumC.
Note that ModNum and ModNumC are not designed to work with arbitrary-length integers, as
they require their integer type to implement the Copy trait.
num dependency to 0.4.ModNum and ModNumC now implement the Hash trait.PartialOrd with reference to generic integers.replace() method.with() method.SaturatingAdd and SaturatingSub documentation.ModNumC.ModNumC, which uses const generics
to enable compile-time checking of compatible modulo. Its functionality is a proper
subset of ModNum.MNum trait to allow ModNumIterator to work with both ModNum and ModNumC.
Note: To use the .a() and .m() methods, be sure to import MNum (or just use bare_metal_modulo::*;)num::Saturating is deprecated.num::Saturating implementation.num::traits::SaturatingAdd
and num::traits::SaturatingSub instead.num::Saturating trait.ModNum as a right-hand side option for arithmetic operators.Display for ModNum objects.