pub trait SaturatingSquare {
type Output;
// Required method
fn saturating_square(self) -> Self::Output;
}
Expand description
Squares a number, saturating at the numeric bounds instead of overflowing.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.