Trait malachite_base::num::arithmetic::traits::SaturatingAddAssign
source · [−]pub trait SaturatingAddAssign<RHS = Self> {
fn saturating_add_assign(&mut self, other: RHS);
}
Expand description
Add a number to another number in place, saturating at the numeric bounds instead of overflowing.
Required Methods
fn saturating_add_assign(&mut self, other: RHS)
Implementations on Foreign Types
sourceimpl SaturatingAddAssign<u8> for u8
impl SaturatingAddAssign<u8> for u8
sourcefn saturating_add_assign(&mut self, other: u8)
fn saturating_add_assign(&mut self, other: u8)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<u16> for u16
impl SaturatingAddAssign<u16> for u16
sourcefn saturating_add_assign(&mut self, other: u16)
fn saturating_add_assign(&mut self, other: u16)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<u32> for u32
impl SaturatingAddAssign<u32> for u32
sourcefn saturating_add_assign(&mut self, other: u32)
fn saturating_add_assign(&mut self, other: u32)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<u64> for u64
impl SaturatingAddAssign<u64> for u64
sourcefn saturating_add_assign(&mut self, other: u64)
fn saturating_add_assign(&mut self, other: u64)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<u128> for u128
impl SaturatingAddAssign<u128> for u128
sourcefn saturating_add_assign(&mut self, other: u128)
fn saturating_add_assign(&mut self, other: u128)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<usize> for usize
impl SaturatingAddAssign<usize> for usize
sourcefn saturating_add_assign(&mut self, other: usize)
fn saturating_add_assign(&mut self, other: usize)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<i8> for i8
impl SaturatingAddAssign<i8> for i8
sourcefn saturating_add_assign(&mut self, other: i8)
fn saturating_add_assign(&mut self, other: i8)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<i16> for i16
impl SaturatingAddAssign<i16> for i16
sourcefn saturating_add_assign(&mut self, other: i16)
fn saturating_add_assign(&mut self, other: i16)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<i32> for i32
impl SaturatingAddAssign<i32> for i32
sourcefn saturating_add_assign(&mut self, other: i32)
fn saturating_add_assign(&mut self, other: i32)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<i64> for i64
impl SaturatingAddAssign<i64> for i64
sourcefn saturating_add_assign(&mut self, other: i64)
fn saturating_add_assign(&mut self, other: i64)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<i128> for i128
impl SaturatingAddAssign<i128> for i128
sourcefn saturating_add_assign(&mut self, other: i128)
fn saturating_add_assign(&mut self, other: i128)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAddAssign<isize> for isize
impl SaturatingAddAssign<isize> for isize
sourcefn saturating_add_assign(&mut self, other: isize)
fn saturating_add_assign(&mut self, other: isize)
Adds a number to another number, in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
x + y & \text{if} \quad m \leq x + y \leq M, \\
M & \text{if} \quad x + y > M, \\
m & \text{if} \quad x + y < m,
\end{cases}
$$
where $m$ is Self::MIN
and $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.