Trait malachite_base::num::arithmetic::traits::XXXSubYYYToZZZ
source · [−]pub trait XXXSubYYYToZZZ: Sized {
fn xxx_sub_yyy_to_zzz(
x_2: Self,
x_1: Self,
x_0: Self,
y_2: Self,
y_1: Self,
y_0: Self
) -> (Self, Self, Self);
}
Expand description
Subtracts two numbers, each composed of three Self
values, returing the difference as a
triple of Self
values.
The more significant number always comes first. Subtraction is wrapping, and overflow is not indicated.
Required Methods
fn xxx_sub_yyy_to_zzz(
x_2: Self,
x_1: Self,
x_0: Self,
y_2: Self,
y_1: Self,
y_0: Self
) -> (Self, Self, Self)
Implementations on Foreign Types
sourceimpl XXXSubYYYToZZZ for u8
impl XXXSubYYYToZZZ for u8
sourcefn xxx_sub_yyy_to_zzz(
x_2: u8,
x_1: u8,
x_0: u8,
y_2: u8,
y_1: u8,
y_0: u8
) -> (u8, u8, u8)
fn xxx_sub_yyy_to_zzz(
x_2: u8,
x_1: u8,
x_0: u8,
y_2: u8,
y_1: u8,
y_0: u8
) -> (u8, u8, u8)
Subtracts two numbers, each composed of three Self
values, returning the
difference as a triple of Self
values.
The more significant value always comes first. Subtraction is wrapping, and overflow is not indicated.
$$
f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and $$ (2^{2W}x_2 + 2^Wx_1 + x_0) - (2^{2W}y_2 + 2^Wy_1 + y_0) \equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \mod 2^{3W}. $$
Worst-case complexity
Constant time and additional memory.
Examples
See here.
This is equivalent to sub_dddmmmsss
from longlong.h
, FLINT 2.7.1, where
(dh, dm, dl)
is returned.
sourceimpl XXXSubYYYToZZZ for u16
impl XXXSubYYYToZZZ for u16
sourcefn xxx_sub_yyy_to_zzz(
x_2: u16,
x_1: u16,
x_0: u16,
y_2: u16,
y_1: u16,
y_0: u16
) -> (u16, u16, u16)
fn xxx_sub_yyy_to_zzz(
x_2: u16,
x_1: u16,
x_0: u16,
y_2: u16,
y_1: u16,
y_0: u16
) -> (u16, u16, u16)
Subtracts two numbers, each composed of three Self
values, returning the
difference as a triple of Self
values.
The more significant value always comes first. Subtraction is wrapping, and overflow is not indicated.
$$
f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and $$ (2^{2W}x_2 + 2^Wx_1 + x_0) - (2^{2W}y_2 + 2^Wy_1 + y_0) \equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \mod 2^{3W}. $$
Worst-case complexity
Constant time and additional memory.
Examples
See here.
This is equivalent to sub_dddmmmsss
from longlong.h
, FLINT 2.7.1, where
(dh, dm, dl)
is returned.
sourceimpl XXXSubYYYToZZZ for u32
impl XXXSubYYYToZZZ for u32
sourcefn xxx_sub_yyy_to_zzz(
x_2: u32,
x_1: u32,
x_0: u32,
y_2: u32,
y_1: u32,
y_0: u32
) -> (u32, u32, u32)
fn xxx_sub_yyy_to_zzz(
x_2: u32,
x_1: u32,
x_0: u32,
y_2: u32,
y_1: u32,
y_0: u32
) -> (u32, u32, u32)
Subtracts two numbers, each composed of three Self
values, returning the
difference as a triple of Self
values.
The more significant value always comes first. Subtraction is wrapping, and overflow is not indicated.
$$
f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and $$ (2^{2W}x_2 + 2^Wx_1 + x_0) - (2^{2W}y_2 + 2^Wy_1 + y_0) \equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \mod 2^{3W}. $$
Worst-case complexity
Constant time and additional memory.
Examples
See here.
This is equivalent to sub_dddmmmsss
from longlong.h
, FLINT 2.7.1, where
(dh, dm, dl)
is returned.
sourceimpl XXXSubYYYToZZZ for u64
impl XXXSubYYYToZZZ for u64
sourcefn xxx_sub_yyy_to_zzz(
x_2: u64,
x_1: u64,
x_0: u64,
y_2: u64,
y_1: u64,
y_0: u64
) -> (u64, u64, u64)
fn xxx_sub_yyy_to_zzz(
x_2: u64,
x_1: u64,
x_0: u64,
y_2: u64,
y_1: u64,
y_0: u64
) -> (u64, u64, u64)
Subtracts two numbers, each composed of three Self
values, returning the
difference as a triple of Self
values.
The more significant value always comes first. Subtraction is wrapping, and overflow is not indicated.
$$
f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and $$ (2^{2W}x_2 + 2^Wx_1 + x_0) - (2^{2W}y_2 + 2^Wy_1 + y_0) \equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \mod 2^{3W}. $$
Worst-case complexity
Constant time and additional memory.
Examples
See here.
This is equivalent to sub_dddmmmsss
from longlong.h
, FLINT 2.7.1, where
(dh, dm, dl)
is returned.
sourceimpl XXXSubYYYToZZZ for u128
impl XXXSubYYYToZZZ for u128
sourcefn xxx_sub_yyy_to_zzz(
x_2: u128,
x_1: u128,
x_0: u128,
y_2: u128,
y_1: u128,
y_0: u128
) -> (u128, u128, u128)
fn xxx_sub_yyy_to_zzz(
x_2: u128,
x_1: u128,
x_0: u128,
y_2: u128,
y_1: u128,
y_0: u128
) -> (u128, u128, u128)
Subtracts two numbers, each composed of three Self
values, returning the
difference as a triple of Self
values.
The more significant value always comes first. Subtraction is wrapping, and overflow is not indicated.
$$
f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and $$ (2^{2W}x_2 + 2^Wx_1 + x_0) - (2^{2W}y_2 + 2^Wy_1 + y_0) \equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \mod 2^{3W}. $$
Worst-case complexity
Constant time and additional memory.
Examples
See here.
This is equivalent to sub_dddmmmsss
from longlong.h
, FLINT 2.7.1, where
(dh, dm, dl)
is returned.
sourceimpl XXXSubYYYToZZZ for usize
impl XXXSubYYYToZZZ for usize
sourcefn xxx_sub_yyy_to_zzz(
x_2: usize,
x_1: usize,
x_0: usize,
y_2: usize,
y_1: usize,
y_0: usize
) -> (usize, usize, usize)
fn xxx_sub_yyy_to_zzz(
x_2: usize,
x_1: usize,
x_0: usize,
y_2: usize,
y_1: usize,
y_0: usize
) -> (usize, usize, usize)
Subtracts two numbers, each composed of three usize
values, returning the difference as
a triple of usize
values.
The more significant value always comes first. Subtraction is wrapping, and overflow is not indicated.
$$
f(x_2, x_1, x_0, y_2, y_1, y_0) = (z_2, z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_2, x_1, x_0, y_2, y_1, y_0, z_2, z_1, z_0 < 2^W$, and $$ (2^{2W}x_2 + 2^Wx_1 + x_0) - (2^{2W}y_2 + 2^Wy_1 + y_0) \equiv 2^{2W}z_2 + 2^Wz_1 + z_0 \mod 2^{3W}. $$
Worst-case complexity
Constant time and additional memory.
Examples
See here.
This is equivalent to sub_dddmmmsss
from longlong.h
, FLINT 2.7.1, where (dh, dm, dl)
is returned.