Trait malachite_base::num::arithmetic::traits::CheckedSubMul
source · [−]pub trait CheckedSubMul<Y = Self, Z = Self> {
type Output;
fn checked_sub_mul(self, y: Y, z: Z) -> Option<Self::Output>;
}
Expand description
Subtracts a number by the product of two other numbers, returning None
if the result is not
representable.
Required Associated Types
Required Methods
fn checked_sub_mul(self, y: Y, z: Z) -> Option<Self::Output>
Implementations on Foreign Types
sourceimpl CheckedSubMul<u8, u8> for u8
impl CheckedSubMul<u8, u8> for u8
sourcefn checked_sub_mul(self, y: u8, z: u8) -> Option<u8>
fn checked_sub_mul(self, y: u8, z: u8) -> Option<u8>
Subtracts a number by 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 \geq yz, \\
\operatorname{None} & \text{if} \quad x < yz,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u8
sourceimpl CheckedSubMul<u16, u16> for u16
impl CheckedSubMul<u16, u16> for u16
sourcefn checked_sub_mul(self, y: u16, z: u16) -> Option<u16>
fn checked_sub_mul(self, y: u16, z: u16) -> Option<u16>
Subtracts a number by 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 \geq yz, \\
\operatorname{None} & \text{if} \quad x < yz,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u16
sourceimpl CheckedSubMul<u32, u32> for u32
impl CheckedSubMul<u32, u32> for u32
sourcefn checked_sub_mul(self, y: u32, z: u32) -> Option<u32>
fn checked_sub_mul(self, y: u32, z: u32) -> Option<u32>
Subtracts a number by 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 \geq yz, \\
\operatorname{None} & \text{if} \quad x < yz,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u32
sourceimpl CheckedSubMul<u64, u64> for u64
impl CheckedSubMul<u64, u64> for u64
sourcefn checked_sub_mul(self, y: u64, z: u64) -> Option<u64>
fn checked_sub_mul(self, y: u64, z: u64) -> Option<u64>
Subtracts a number by 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 \geq yz, \\
\operatorname{None} & \text{if} \quad x < yz,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u64
sourceimpl CheckedSubMul<u128, u128> for u128
impl CheckedSubMul<u128, u128> for u128
sourcefn checked_sub_mul(self, y: u128, z: u128) -> Option<u128>
fn checked_sub_mul(self, y: u128, z: u128) -> Option<u128>
Subtracts a number by 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 \geq yz, \\
\operatorname{None} & \text{if} \quad x < yz,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = u128
sourceimpl CheckedSubMul<usize, usize> for usize
impl CheckedSubMul<usize, usize> for usize
sourcefn checked_sub_mul(self, y: usize, z: usize) -> Option<usize>
fn checked_sub_mul(self, y: usize, z: usize) -> Option<usize>
Subtracts a number by 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 \geq yz, \\
\operatorname{None} & \text{if} \quad x < yz,
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = usize
sourceimpl CheckedSubMul<i8, i8> for i8
impl CheckedSubMul<i8, i8> for i8
sourcefn checked_sub_mul(self, y: i8, z: i8) -> Option<i8>
fn checked_sub_mul(self, y: i8, z: i8) -> Option<i8>
Subtracts a number by 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}
\ xy - z \geq 2^{W-1}, \\
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i8
sourceimpl CheckedSubMul<i16, i16> for i16
impl CheckedSubMul<i16, i16> for i16
sourcefn checked_sub_mul(self, y: i16, z: i16) -> Option<i16>
fn checked_sub_mul(self, y: i16, z: i16) -> Option<i16>
Subtracts a number by 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}
\ xy - z \geq 2^{W-1}, \\
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i16
sourceimpl CheckedSubMul<i32, i32> for i32
impl CheckedSubMul<i32, i32> for i32
sourcefn checked_sub_mul(self, y: i32, z: i32) -> Option<i32>
fn checked_sub_mul(self, y: i32, z: i32) -> Option<i32>
Subtracts a number by 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}
\ xy - z \geq 2^{W-1}, \\
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i32
sourceimpl CheckedSubMul<i64, i64> for i64
impl CheckedSubMul<i64, i64> for i64
sourcefn checked_sub_mul(self, y: i64, z: i64) -> Option<i64>
fn checked_sub_mul(self, y: i64, z: i64) -> Option<i64>
Subtracts a number by 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}
\ xy - z \geq 2^{W-1}, \\
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i64
sourceimpl CheckedSubMul<i128, i128> for i128
impl CheckedSubMul<i128, i128> for i128
sourcefn checked_sub_mul(self, y: i128, z: i128) -> Option<i128>
fn checked_sub_mul(self, y: i128, z: i128) -> Option<i128>
Subtracts a number by 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}
\ xy - z \geq 2^{W-1}, \\
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
type Output = i128
sourceimpl CheckedSubMul<isize, isize> for isize
impl CheckedSubMul<isize, isize> for isize
sourcefn checked_sub_mul(self, y: isize, z: isize) -> Option<isize>
fn checked_sub_mul(self, y: isize, z: isize) -> Option<isize>
Subtracts a number by 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}
\ xy - z \geq 2^{W-1}, \\
\end{cases}
$$
where $W$ is Self::WIDTH
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.