pub trait XXAddYYToZZ: Sized {
// Required method
fn xx_add_yy_to_zz(
x_1: Self,
x_0: Self,
y_1: Self,
y_0: Self,
) -> (Self, Self);
}
Expand description
Adds two numbers, each composed of two Self
values, returning the sum as a pair of Self
values.
The more significant number always comes first. Addition is wrapping, and overflow is not indicated.
Required Methods§
fn xx_add_yy_to_zz(x_1: Self, x_0: Self, y_1: Self, y_0: Self) -> (Self, Self)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl XXAddYYToZZ for u8
impl XXAddYYToZZ for u8
Source§fn xx_add_yy_to_zz(x_1: u8, x_0: u8, y_1: u8, y_0: u8) -> (u8, u8)
fn xx_add_yy_to_zz(x_1: u8, x_0: u8, y_1: u8, y_0: u8) -> (u8, u8)
Adds two numbers, each composed of two Self
values, returning the sum as a pair of
Self
values.
The more significant value always comes first. Addition is wrapping, and overflow is not indicated.
$$
f(x_1, x_0, y_1, y_0) = (z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and $$ (2^Wx_1 + x_0) + (2^Wy_1 + y_0) \equiv 2^Wz_1 + z_0 \mod 2^{2W}. $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
This is equivalent to add_ssaaaa
from longlong.h
, GMP 6.2.1, where (sh, sl)
is
returned.
Source§impl XXAddYYToZZ for u16
impl XXAddYYToZZ for u16
Source§fn xx_add_yy_to_zz(x_1: u16, x_0: u16, y_1: u16, y_0: u16) -> (u16, u16)
fn xx_add_yy_to_zz(x_1: u16, x_0: u16, y_1: u16, y_0: u16) -> (u16, u16)
Adds two numbers, each composed of two Self
values, returning the sum as a pair of
Self
values.
The more significant value always comes first. Addition is wrapping, and overflow is not indicated.
$$
f(x_1, x_0, y_1, y_0) = (z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and $$ (2^Wx_1 + x_0) + (2^Wy_1 + y_0) \equiv 2^Wz_1 + z_0 \mod 2^{2W}. $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
This is equivalent to add_ssaaaa
from longlong.h
, GMP 6.2.1, where (sh, sl)
is
returned.
Source§impl XXAddYYToZZ for u32
impl XXAddYYToZZ for u32
Source§fn xx_add_yy_to_zz(x_1: u32, x_0: u32, y_1: u32, y_0: u32) -> (u32, u32)
fn xx_add_yy_to_zz(x_1: u32, x_0: u32, y_1: u32, y_0: u32) -> (u32, u32)
Adds two numbers, each composed of two Self
values, returning the sum as a pair of
Self
values.
The more significant value always comes first. Addition is wrapping, and overflow is not indicated.
$$
f(x_1, x_0, y_1, y_0) = (z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and $$ (2^Wx_1 + x_0) + (2^Wy_1 + y_0) \equiv 2^Wz_1 + z_0 \mod 2^{2W}. $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
This is equivalent to add_ssaaaa
from longlong.h
, GMP 6.2.1, where (sh, sl)
is
returned.
Source§impl XXAddYYToZZ for u64
impl XXAddYYToZZ for u64
Source§fn xx_add_yy_to_zz(x_1: u64, x_0: u64, y_1: u64, y_0: u64) -> (u64, u64)
fn xx_add_yy_to_zz(x_1: u64, x_0: u64, y_1: u64, y_0: u64) -> (u64, u64)
Adds two numbers, each composed of two Self
values, returning the sum as a pair of
Self
values.
The more significant value always comes first. Addition is wrapping, and overflow is not indicated.
$$
f(x_1, x_0, y_1, y_0) = (z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and $$ (2^Wx_1 + x_0) + (2^Wy_1 + y_0) \equiv 2^Wz_1 + z_0 \mod 2^{2W}. $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
This is equivalent to add_ssaaaa
from longlong.h
, GMP 6.2.1, where (sh, sl)
is
returned.
Source§impl XXAddYYToZZ for u128
impl XXAddYYToZZ for u128
Source§fn xx_add_yy_to_zz(x_1: u128, x_0: u128, y_1: u128, y_0: u128) -> (u128, u128)
fn xx_add_yy_to_zz(x_1: u128, x_0: u128, y_1: u128, y_0: u128) -> (u128, u128)
Adds two numbers, each composed of two u128
values, returning the sum as a pair of
u128
values.
The more significant value always comes first. Addition is wrapping, and overflow is not indicated.
$$
f(x_1, x_0, y_1, y_0) = (z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and $$ (2^Wx_1 + x_0) + (2^Wy_1 + y_0) \equiv 2^Wz_1 + z_0 \mod 2^{2W}. $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
This is equivalent to add_ssaaaa
from longlong.h
, GMP 6.2.1, where (sh, sl)
is
returned.
Source§impl XXAddYYToZZ for usize
impl XXAddYYToZZ for usize
Source§fn xx_add_yy_to_zz(
x_1: usize,
x_0: usize,
y_1: usize,
y_0: usize,
) -> (usize, usize)
fn xx_add_yy_to_zz( x_1: usize, x_0: usize, y_1: usize, y_0: usize, ) -> (usize, usize)
Adds two numbers, each composed of two usize
values, returning the sum as a pair of
usize
values.
The more significant value always comes first. Addition is wrapping, and overflow is not indicated.
$$
f(x_1, x_0, y_1, y_0) = (z_1, z_0),
$$
where $W$ is Self::WIDTH
,
$x_1, x_0, y_1, y_0, z_1, z_0 < 2^W$, and $$ (2^Wx_1 + x_0) + (2^Wy_1 + y_0) \equiv 2^Wz_1 + z_0 \mod 2^{2W}. $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
This is equivalent to add_ssaaaa
from longlong.h
, GMP 6.2.1, where (sh, sl)
is
returned.