pub trait CheckedAddMul<Y = Self, Z = Self> {
    type Output;

    fn checked_add_mul(self, y: Y, z: Z) -> Option<Self::Output>;
}
Expand description

Adds a number and the product of two other numbers, returning None if the result is not representable.

Required Associated Types

Required Methods

Implementations on Foreign Types

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad x + yz < 2^W, \\ \operatorname{None} & \text{if} \quad x + yz \geq 2^W, \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad x + yz < 2^W, \\ \operatorname{None} & \text{if} \quad x + yz \geq 2^W, \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad x + yz < 2^W, \\ \operatorname{None} & \text{if} \quad x + yz \geq 2^W, \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad x + yz < 2^W, \\ \operatorname{None} & \text{if} \quad x + yz \geq 2^W, \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad x + yz < 2^W, \\ \operatorname{None} & \text{if} \quad x + yz \geq 2^W, \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad x + yz < 2^W, \\ \operatorname{None} & \text{if} \quad x + yz \geq 2^W, \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad -2^{W-1} \leq x + yz < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad x + yz < -2^{W-1} \ \mathrm{or} \ x + yz \geq 2^{W-1}, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad -2^{W-1} \leq x + yz < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad x + yz < -2^{W-1} \ \mathrm{or} \ x + yz \geq 2^{W-1}, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad -2^{W-1} \leq x + yz < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad x + yz < -2^{W-1} \ \mathrm{or} \ x + yz \geq 2^{W-1}, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad -2^{W-1} \leq x + yz < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad x + yz < -2^{W-1} \ \mathrm{or} \ x + yz \geq 2^{W-1}, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad -2^{W-1} \leq x + yz < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad x + yz < -2^{W-1} \ \mathrm{or} \ x + yz \geq 2^{W-1}, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Adds a number and the product of two other numbers, returning None if the result cannot be represented.

$$ f(x, y, z) = \begin{cases} \operatorname{Some}(x + yz) & \text{if} \quad -2^{W-1} \leq x + yz < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad x + yz < -2^{W-1} \ \mathrm{or} \ x + yz \geq 2^{W-1}, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Implementors