Trait malachite_base::num::arithmetic::traits::SaturatingNegAssign
source · pub trait SaturatingNegAssign {
// Required method
fn saturating_neg_assign(&mut self);
}
Expand description
Negates a number in place, saturating at the numeric bounds instead of overflowing.
Required Methods§
fn saturating_neg_assign(&mut self)
Implementations on Foreign Types§
source§impl SaturatingNegAssign for i8
impl SaturatingNegAssign for i8
source§fn saturating_neg_assign(&mut self)
fn saturating_neg_assign(&mut self)
Negates a number in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
-x & \text{if} \quad x^2 > -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.
source§impl SaturatingNegAssign for i16
impl SaturatingNegAssign for i16
source§fn saturating_neg_assign(&mut self)
fn saturating_neg_assign(&mut self)
Negates a number in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
-x & \text{if} \quad x^2 > -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.
source§impl SaturatingNegAssign for i32
impl SaturatingNegAssign for i32
source§fn saturating_neg_assign(&mut self)
fn saturating_neg_assign(&mut self)
Negates a number in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
-x & \text{if} \quad x^2 > -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.
source§impl SaturatingNegAssign for i64
impl SaturatingNegAssign for i64
source§fn saturating_neg_assign(&mut self)
fn saturating_neg_assign(&mut self)
Negates a number in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
-x & \text{if} \quad x^2 > -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.
source§impl SaturatingNegAssign for i128
impl SaturatingNegAssign for i128
source§fn saturating_neg_assign(&mut self)
fn saturating_neg_assign(&mut self)
Negates a number in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
-x & \text{if} \quad x^2 > -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.
source§impl SaturatingNegAssign for isize
impl SaturatingNegAssign for isize
source§fn saturating_neg_assign(&mut self)
fn saturating_neg_assign(&mut self)
Negates a number in place, saturating at the numeric bounds instead of overflowing.
$$
x \gets \begin{cases}
-x & \text{if} \quad x^2 > -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.