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

Implementations on Foreign Types

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.

Implementors