Trait malachite_base::num::arithmetic::traits::SaturatingSquare
source · [−]pub trait SaturatingSquare {
type Output;
fn saturating_square(self) -> Self::Output;
}
Expand description
Squares a number, saturating at the numeric bounds instead of overflowing.
Required Associated Types
Required Methods
fn saturating_square(self) -> Self::Output
Implementations on Foreign Types
sourceimpl SaturatingSquare for u8
impl SaturatingSquare for u8
sourcefn saturating_square(self) -> u8
fn saturating_square(self) -> u8
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u8
sourceimpl SaturatingSquare for u16
impl SaturatingSquare for u16
sourcefn saturating_square(self) -> u16
fn saturating_square(self) -> u16
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u16
sourceimpl SaturatingSquare for u32
impl SaturatingSquare for u32
sourcefn saturating_square(self) -> u32
fn saturating_square(self) -> u32
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u32
sourceimpl SaturatingSquare for u64
impl SaturatingSquare for u64
sourcefn saturating_square(self) -> u64
fn saturating_square(self) -> u64
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u64
sourceimpl SaturatingSquare for u128
impl SaturatingSquare for u128
sourcefn saturating_square(self) -> u128
fn saturating_square(self) -> u128
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u128
sourceimpl SaturatingSquare for usize
impl SaturatingSquare for usize
sourcefn saturating_square(self) -> usize
fn saturating_square(self) -> usize
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = usize
sourceimpl SaturatingSquare for i8
impl SaturatingSquare for i8
sourcefn saturating_square(self) -> i8
fn saturating_square(self) -> i8
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i8
sourceimpl SaturatingSquare for i16
impl SaturatingSquare for i16
sourcefn saturating_square(self) -> i16
fn saturating_square(self) -> i16
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i16
sourceimpl SaturatingSquare for i32
impl SaturatingSquare for i32
sourcefn saturating_square(self) -> i32
fn saturating_square(self) -> i32
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i32
sourceimpl SaturatingSquare for i64
impl SaturatingSquare for i64
sourcefn saturating_square(self) -> i64
fn saturating_square(self) -> i64
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i64
sourceimpl SaturatingSquare for i128
impl SaturatingSquare for i128
sourcefn saturating_square(self) -> i128
fn saturating_square(self) -> i128
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i128
sourceimpl SaturatingSquare for isize
impl SaturatingSquare for isize
sourcefn saturating_square(self) -> isize
fn saturating_square(self) -> isize
Squares a number, saturating at the numeric bounds instead of overflowing.
$$
f(x) = \begin{cases}
x^2 & \text{if} \quad x^2 \leq M, \\
M & \text{if} \quad x^2 > M,
\end{cases}
$$
where $M$ is Self::MAX
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.