Module num

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 as operator, which admits narrowing and precision loss. Implementers of this trait AsPrimitive should 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 0 and 1 values, 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.
PrimUnsignedInt
Functions for primitive unsigned integral types.
Saturating
Saturating math operations. Deprecated, use SaturatingAdd, SaturatingSub and SaturatingMul instead.
Signed
Useful functions for signed numbers (i.e. numbers that can be negative).
Unsigned
A trait for values which cannot be negative
WrappingAdd
Performs addition that wraps around on overflow.
WrappingMul
Performs multiplication that wraps around on overflow.
WrappingShl
Performs a left shift that does not panic.
WrappingShr
Performs a right shift that does not panic.
WrappingSub
Performs subtraction that wraps around on overflow.
Zero
Defines an additive identity element for Self.