Trait malachite_base::num::arithmetic::traits::SaturatingAbsAssign
source · [−]pub trait SaturatingAbsAssign {
fn saturating_abs_assign(&mut self);
}
Expand description
Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.
Required Methods
fn saturating_abs_assign(&mut self)
Implementations on Foreign Types
sourceimpl SaturatingAbsAssign for i8
impl SaturatingAbsAssign for i8
sourcefn saturating_abs_assign(&mut self)
fn saturating_abs_assign(&mut self)
Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
|x| & \text{if} \quad x > -2^{W-1}, \\
2^{W-1} - 1 & \text{if} \quad x = -2^{W-1},
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAbsAssign for i16
impl SaturatingAbsAssign for i16
sourcefn saturating_abs_assign(&mut self)
fn saturating_abs_assign(&mut self)
Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
|x| & \text{if} \quad x > -2^{W-1}, \\
2^{W-1} - 1 & \text{if} \quad x = -2^{W-1},
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAbsAssign for i32
impl SaturatingAbsAssign for i32
sourcefn saturating_abs_assign(&mut self)
fn saturating_abs_assign(&mut self)
Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
|x| & \text{if} \quad x > -2^{W-1}, \\
2^{W-1} - 1 & \text{if} \quad x = -2^{W-1},
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAbsAssign for i64
impl SaturatingAbsAssign for i64
sourcefn saturating_abs_assign(&mut self)
fn saturating_abs_assign(&mut self)
Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
|x| & \text{if} \quad x > -2^{W-1}, \\
2^{W-1} - 1 & \text{if} \quad x = -2^{W-1},
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAbsAssign for i128
impl SaturatingAbsAssign for i128
sourcefn saturating_abs_assign(&mut self)
fn saturating_abs_assign(&mut self)
Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
|x| & \text{if} \quad x > -2^{W-1}, \\
2^{W-1} - 1 & \text{if} \quad x = -2^{W-1},
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SaturatingAbsAssign for isize
impl SaturatingAbsAssign for isize
sourcefn saturating_abs_assign(&mut self)
fn saturating_abs_assign(&mut self)
Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
|x| & \text{if} \quad x > -2^{W-1}, \\
2^{W-1} - 1 & \text{if} \quad x = -2^{W-1},
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.