Module num
Expand description
Additional functionality for numerics.
This module provides traits that are useful when doing numerical work. See the individual documentation for each piece for more information.
Traitsยง
- AsPrimitive
- A generic interface for casting between machine scalars with the
asoperator, which admits narrowing and precision loss. Implementers of this traitAsPrimitiveshould behave like a primitive numeric type (e.g. a newtype around another primitive), and the intended conversion must never fail. - Bounded
- Numbers which have upper and lower bounds
- NonZero
- Functions for primitive type, which has a non-zero correspondant.
- Num
- The base trait for numeric types, covering
0and1values, comparisons, basic numeric operations, and string conversion. - NumCast
- An interface for casting between machine scalars.
- NumOps
- Generic trait for types implementing basic numeric operations
- One
- Defines a multiplicative identity element for
Self. - PrimInt
- Generic trait for primitive integers.
- Prim
Unsigned Int - Functions for primitive unsigned integral types.
- Saturating
- Saturating math operations. Deprecated, use
SaturatingAdd,SaturatingSubandSaturatingMulinstead. - Signed
- Useful functions for signed numbers (i.e. numbers that can be negative).
- Unsigned
- A trait for values which cannot be negative
- Wrapping
Add - Performs addition that wraps around on overflow.
- Wrapping
Mul - Performs multiplication that wraps around on overflow.
- Wrapping
Shl - Performs a left shift that does not panic.
- Wrapping
Shr - Performs a right shift that does not panic.
- Wrapping
Sub - Performs subtraction that wraps around on overflow.
- Zero
- Defines an additive identity element for
Self.