Expand description
Traits for “local” numbers
Sometimes, a given type T only has the concept of zero and one local to self.
E.g. the 5-adic space ZZ_5 has zero in it, but it is not the same zero as in ZZ_7.
Same with one, shared concepts but in a “subspace” of T.
So a function to create zero or one needs extra information than the traits
Zero
and One
in num.
The obvious “extra” information is self.
Built on top of this are the constructed traits of LocalNum and LocalInteger.
These follow similarly to the num crate with two major differences:
- They only require
LocalZeroandLocalOneinstead ofZeroandOne - They don’t rely on information about number ordering, such as floor and ceil
Traits:
LocalZeroasks forzero(Self)rather thanzero()LocalOneasks forone(Self)rather thanone()LocalNumthe base type for a ring-like structure, with local zero/one and ring opsLocalIntegeraLocalNumthat has an idea of GCD/LCM
Traits§
- Local
Integer - A
LocalNumthat allows division, remainder, GCD, and LCM - Local
Num - The base trait for numeric types, covering local 0 and 1 values, comparisons, basic numeric operations, and string conversion
- Local
One - Returns a multiplicative identity element for
self - Local
Zero - Returns an additive identity element for
self