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.
Numbers which have upper and lower bounds
Performs addition that returns None
instead of wrapping around on
overflow.
Performs division that returns None
instead of panicking on division by zero and instead of
wrapping around on underflow and overflow.
Performs multiplication that returns None
instead of wrapping around on underflow or
overflow.
Performs negation that returns None
if the result can’t be represented.
Performs an integral remainder that returns None
instead of panicking on division by zero and
instead of wrapping around on underflow and overflow.
Performs a left shift that returns None
on shifts larger than
or equal to the type width.
Performs a right shift that returns None
on shifts larger than
or equal to the type width.
Performs subtraction that returns None
instead of wrapping around on underflow.
Defines an associated constant representing the multiplicative identity
element for Self
.
Defines an associated constant representing the additive identity element
for Self
.
Generic trait for floating point numbers
A generic trait for converting a number to a value.
Unary operator for retrieving the multiplicative inverse, or reciprocal, of a value.
Fused multiply-add. Computes (self * a) + b
with only one rounding
error, yielding a more accurate result than an unfused multiply-add.
The fused multiply-add assignment operation *self = (*self * a) + b
The base trait for numeric types, covering 0
and 1
values,
comparisons, basic numeric operations, and string conversion.
The trait for Num
types which also implement assignment operators.
Generic trait for types implementing numeric assignment operators (like +=
).
The trait for NumAssign
types which also implement assignment operations
taking the second operand by reference.
An interface for casting between machine scalars.
Generic trait for types implementing basic numeric operations
The trait for Num
types which also implement numeric operations taking
the second operand by reference.
Defines a multiplicative identity element for Self
.
Binary operator for raising a value to a power.
Generic trait for primitive integers.
The trait for Num
references which implement numeric operations, taking the
second operand either by value or by reference.
Saturating math operations. Deprecated, use SaturatingAdd
, SaturatingSub
and
SaturatingMul
instead.
Performs addition that saturates at the numeric bounds instead of overflowing.
Performs multiplication that saturates at the numeric bounds instead of overflowing.
Performs subtraction that saturates at the numeric bounds instead of overflowing.
Useful functions for signed numbers (i.e. numbers that can be negative).
A generic trait for converting a value to a number.
A trait for values which cannot be negative
Performs addition that wraps around on overflow.
Performs multiplication that wraps around on overflow.
Performs a negation that does not panic.
Performs a left shift that does not panic.
Performs a right shift that does not panic.
Performs subtraction that wraps around on overflow.
Defines an additive identity element for Self
.