Trait malachite_base::num::arithmetic::traits::CheckedSubMul
source · pub trait CheckedSubMul<Y = Self, Z = Self> {
type Output;
// Required method
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§
source§impl CheckedSubMul for i8
impl CheckedSubMul for i8
source§fn 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
source§impl CheckedSubMul for i16
impl CheckedSubMul for i16
source§fn 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
source§impl CheckedSubMul for i32
impl CheckedSubMul for i32
source§fn 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
source§impl CheckedSubMul for i64
impl CheckedSubMul for i64
source§fn 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
source§impl CheckedSubMul for i128
impl CheckedSubMul for i128
source§fn 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
source§impl CheckedSubMul for isize
impl CheckedSubMul for isize
source§fn 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.
type Output = isize
source§impl CheckedSubMul for u8
impl CheckedSubMul for u8
source§fn 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
source§impl CheckedSubMul for u16
impl CheckedSubMul for u16
source§fn 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
source§impl CheckedSubMul for u32
impl CheckedSubMul for u32
source§fn 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
source§impl CheckedSubMul for u64
impl CheckedSubMul for u64
source§fn 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
source§impl CheckedSubMul for u128
impl CheckedSubMul for u128
source§fn 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
source§impl CheckedSubMul for usize
impl CheckedSubMul for usize
source§fn 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.