Trait malachite_base::num::conversion::traits::SplitInHalf
source · [−]pub trait SplitInHalf: HasHalf {
fn lower_half(&self) -> Self::Half;
fn upper_half(&self) -> Self::Half;
fn split_in_half(&self) -> (Self::Half, Self::Half) { ... }
}
Expand description
Required Methods
fn lower_half(&self) -> Self::Half
fn lower_half(&self) -> Self::Half
Extracts the lower, or least-significant, half of a number.
fn upper_half(&self) -> Self::Half
fn upper_half(&self) -> Self::Half
Extracts the upper, or most-significant half of a number.
Provided Methods
Extracts both halves of a number; the upper, or most-significant, half comes first.
Worst-case complexity
$T(n) = O(\max(T_U(n), T_L(n)))$
$M(n) = O(\max(M_U(n), M_L(n)))$
where $T$ is time, $M$ is additional memory, $T_U$ and $T_L$ are the time complexities of
the upper_half
and lower_half
functions,
respectively, and $M_U$ and $M_L$ are the memory complexities of the
upper_half
and lower_half
functions,
respectively.
Implementations on Foreign Types
sourceimpl SplitInHalf for u16
impl SplitInHalf for u16
sourcefn lower_half(&self) -> Self::Half
fn lower_half(&self) -> Self::Half
Extracts the lower, or least significant, half of an unsigned integer.
Let $W$ be the width of Self
(the input type).
$f(n) = m$, where $m < 2^{W/2}$ and $n + 2^{W/2} k = m$ for some $k \in \Z$.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourcefn upper_half(&self) -> Self::Half
fn upper_half(&self) -> Self::Half
Extracts the upper, or most-significant, half of an unsigned integer.
Let $W$ be the width of Self
(the input type).
$f(n) = \lfloor \frac{n}{2^{W/2}} \rfloor$.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SplitInHalf for u32
impl SplitInHalf for u32
sourcefn lower_half(&self) -> Self::Half
fn lower_half(&self) -> Self::Half
Extracts the lower, or least significant, half of an unsigned integer.
Let $W$ be the width of Self
(the input type).
$f(n) = m$, where $m < 2^{W/2}$ and $n + 2^{W/2} k = m$ for some $k \in \Z$.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourcefn upper_half(&self) -> Self::Half
fn upper_half(&self) -> Self::Half
Extracts the upper, or most-significant, half of an unsigned integer.
Let $W$ be the width of Self
(the input type).
$f(n) = \lfloor \frac{n}{2^{W/2}} \rfloor$.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SplitInHalf for u64
impl SplitInHalf for u64
sourcefn lower_half(&self) -> Self::Half
fn lower_half(&self) -> Self::Half
Extracts the lower, or least significant, half of an unsigned integer.
Let $W$ be the width of Self
(the input type).
$f(n) = m$, where $m < 2^{W/2}$ and $n + 2^{W/2} k = m$ for some $k \in \Z$.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourcefn upper_half(&self) -> Self::Half
fn upper_half(&self) -> Self::Half
Extracts the upper, or most-significant, half of an unsigned integer.
Let $W$ be the width of Self
(the input type).
$f(n) = \lfloor \frac{n}{2^{W/2}} \rfloor$.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl SplitInHalf for u128
impl SplitInHalf for u128
sourcefn lower_half(&self) -> Self::Half
fn lower_half(&self) -> Self::Half
Extracts the lower, or least significant, half of an unsigned integer.
Let $W$ be the width of Self
(the input type).
$f(n) = m$, where $m < 2^{W/2}$ and $n + 2^{W/2} k = m$ for some $k \in \Z$.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourcefn upper_half(&self) -> Self::Half
fn upper_half(&self) -> Self::Half
Extracts the upper, or most-significant, half of an unsigned integer.
Let $W$ be the width of Self
(the input type).
$f(n) = \lfloor \frac{n}{2^{W/2}} \rfloor$.
Worst-case complexity
Constant time and additional memory.
Examples
See here.