Skip to main content

CheckedMulAddMul

Trait CheckedMulAddMul 

Source
pub trait CheckedMulAddMul<Y = Self, Z = Self, W = Self> {
    type Output;

    // Required method
    fn checked_mul_add_mul(self, y: Y, z: Z, w: W) -> Option<Self::Output>;
}
Expand description

Adds the products of two pairs of numbers, returning None if the result is not representable.

Required Associated Types§

Required Methods§

Source

fn checked_mul_add_mul(self, y: Y, z: Z, w: W) -> Option<Self::Output>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl CheckedMulAddMul for i8

Source§

fn checked_mul_add_mul(self, y: i8, z: i8, w: i8) -> Option<i8>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i8

Source§

impl CheckedMulAddMul for i16

Source§

fn checked_mul_add_mul(self, y: i16, z: i16, w: i16) -> Option<i16>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i16

Source§

impl CheckedMulAddMul for i32

Source§

fn checked_mul_add_mul(self, y: i32, z: i32, w: i32) -> Option<i32>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i32

Source§

impl CheckedMulAddMul for i64

Source§

fn checked_mul_add_mul(self, y: i64, z: i64, w: i64) -> Option<i64>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i64

Source§

impl CheckedMulAddMul for i128

Source§

fn checked_mul_add_mul(self, y: i128, z: i128, w: i128) -> Option<i128>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i128

Source§

impl CheckedMulAddMul for isize

Source§

fn checked_mul_add_mul(self, y: isize, z: isize, w: isize) -> Option<isize>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = isize

Source§

impl CheckedMulAddMul for u8

Source§

fn checked_mul_add_mul(self, y: u8, z: u8, w: u8) -> Option<u8>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u8

Source§

impl CheckedMulAddMul for u16

Source§

fn checked_mul_add_mul(self, y: u16, z: u16, w: u16) -> Option<u16>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u16

Source§

impl CheckedMulAddMul for u32

Source§

fn checked_mul_add_mul(self, y: u32, z: u32, w: u32) -> Option<u32>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u32

Source§

impl CheckedMulAddMul for u64

Source§

fn checked_mul_add_mul(self, y: u64, z: u64, w: u64) -> Option<u64>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u64

Source§

impl CheckedMulAddMul for u128

Source§

fn checked_mul_add_mul(self, y: u128, z: u128, w: u128) -> Option<u128>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u128

Source§

impl CheckedMulAddMul for usize

Source§

fn checked_mul_add_mul(self, y: usize, z: usize, w: usize) -> Option<usize>

Adds the products of two pairs of numbers, returning None if the result cannot be represented.

$$ f(x, y, z, w) = \begin{cases} xy + zw & \text{if} \quad xy + zw \ \text{is representable} \\ \operatorname{None} & \text{otherwise} \end{cases} $$

The products are formed at double width, so a product that does not fit does not by itself make the result unrepresentable.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = usize

Implementors§