Trait malachite_base::num::conversion::traits::PowerOf2Digits
source · pub trait PowerOf2Digits<T>: Sized {
// Required methods
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<T>;
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<T>;
fn from_power_of_2_digits_asc<I: Iterator<Item = T>>(
log_base: u64,
digits: I,
) -> Option<Self>;
fn from_power_of_2_digits_desc<I: Iterator<Item = T>>(
log_base: u64,
digits: I,
) -> Option<Self>;
}
Expand description
Expresses a value as a Vec
of base-$2^k$ digits, or reads a value from an iterator of
base-$2^k$ digits.
The trait is parameterized by the digit type.
Required Methods§
sourcefn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<T>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<T>
Returns a Vec
containing the digits of a value in ascending order: least- to
most-significant.
The base is $2^k$, where $k$ is log_base
.
sourcefn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<T>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<T>
Returns a Vec
containing the digits of a value in descending order: most- to
least-significant.
The base is $2^k$, where $k$ is log_base
.
sourcefn from_power_of_2_digits_asc<I: Iterator<Item = T>>(
log_base: u64,
digits: I,
) -> Option<Self>
fn from_power_of_2_digits_asc<I: Iterator<Item = T>>( log_base: u64, digits: I, ) -> Option<Self>
Converts an iterator of digits into a value.
The input digits are in ascending order: least- to most-significant. The base is $2^k$,
where $k$ is log_base
.
sourcefn from_power_of_2_digits_desc<I: Iterator<Item = T>>(
log_base: u64,
digits: I,
) -> Option<Self>
fn from_power_of_2_digits_desc<I: Iterator<Item = T>>( log_base: u64, digits: I, ) -> Option<Self>
Converts an iterator of digits into a value.
The input digits are in descending order: most- to least-significant. The base is $2^k$,
where $k$ is log_base
.
Object Safety§
Implementations on Foreign Types§
source§impl PowerOf2Digits<u8> for u8
impl PowerOf2Digits<u8> for u8
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u8> for u16
impl PowerOf2Digits<u8> for u16
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u8> for u32
impl PowerOf2Digits<u8> for u32
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u8> for u64
impl PowerOf2Digits<u8> for u64
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u8> for u128
impl PowerOf2Digits<u8> for u128
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u8> for usize
impl PowerOf2Digits<u8> for usize
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u8>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_asc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_desc<I: Iterator<Item = u8>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u16> for u8
impl PowerOf2Digits<u16> for u8
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u16> for u16
impl PowerOf2Digits<u16> for u16
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u16> for u32
impl PowerOf2Digits<u16> for u32
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u16> for u64
impl PowerOf2Digits<u16> for u64
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u16> for u128
impl PowerOf2Digits<u16> for u128
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u16> for usize
impl PowerOf2Digits<u16> for usize
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u16>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_asc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_desc<I: Iterator<Item = u16>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u32> for u8
impl PowerOf2Digits<u32> for u8
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u32> for u16
impl PowerOf2Digits<u32> for u16
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u32> for u32
impl PowerOf2Digits<u32> for u32
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u32> for u64
impl PowerOf2Digits<u32> for u64
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u32> for u128
impl PowerOf2Digits<u32> for u128
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u32> for usize
impl PowerOf2Digits<u32> for usize
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u32>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_asc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_desc<I: Iterator<Item = u32>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u64> for u8
impl PowerOf2Digits<u64> for u8
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u64> for u16
impl PowerOf2Digits<u64> for u16
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u64> for u32
impl PowerOf2Digits<u64> for u32
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u64> for u64
impl PowerOf2Digits<u64> for u64
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u64> for u128
impl PowerOf2Digits<u64> for u128
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u64> for usize
impl PowerOf2Digits<u64> for usize
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u64>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_asc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_desc<I: Iterator<Item = u64>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u128> for u8
impl PowerOf2Digits<u128> for u8
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u128> for u16
impl PowerOf2Digits<u128> for u16
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u128> for u32
impl PowerOf2Digits<u128> for u32
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u128> for u64
impl PowerOf2Digits<u128> for u64
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u128> for u128
impl PowerOf2Digits<u128> for u128
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<u128> for usize
impl PowerOf2Digits<u128> for usize
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<u128>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_asc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_desc<I: Iterator<Item = u128>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<usize> for u8
impl PowerOf2Digits<usize> for u8
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u8>
fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u8>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<usize> for u16
impl PowerOf2Digits<usize> for u16
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u16>
fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u16>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<usize> for u32
impl PowerOf2Digits<usize> for u32
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u32>
fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u32>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<usize> for u64
impl PowerOf2Digits<usize> for u64
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u64>
fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u64>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<usize> for u128
impl PowerOf2Digits<usize> for u128
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<u128>
fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<u128>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§impl PowerOf2Digits<usize> for usize
impl PowerOf2Digits<usize> for usize
source§fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_asc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in ascending
order (least- to most-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it ends with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_{n-1} \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{ki}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
fn to_power_of_2_digits_desc(&self, log_base: u64) -> Vec<usize>
Returns a Vec
containing the base-$2^k$ digits of a number in descending
order (most- to least-significant).
The base-2 logarithm of the base is specified. log_base
must be no larger
than the width of the digit type. If self
is 0, the Vec
is empty;
otherwise, it begins with a nonzero digit.
$f(x, k) = (d_i)_ {i=0}^{n-1}$, where $0 \leq d_i < 2^k$ for all $i$, $n=0$ or $d_0 \neq 0$, and
$$ \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i = x. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
self.significant_bits()
.
§Panics
Panics if log_base
is greater than the width of the output type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_asc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
ascending order (least- to most-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{ki}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.
source§fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>(
log_base: u64,
digits: I,
) -> Option<usize>
fn from_power_of_2_digits_desc<I: Iterator<Item = usize>>( log_base: u64, digits: I, ) -> Option<usize>
Converts an iterator of base-$2^k$ digits into a value.
The base-2 logarithm of the base is specified. The input digits are in
descending order (most- to least-significant). log_base
must be no larger
than the width of the digit type. The function returns None
if the input
represents a number that can’t fit in the output type.
$$ f((d_i)_ {i=0}^{n-1}, k) = \sum_{i=0}^{n-1}2^{k (n-i-1)}d_i. $$
§Worst-case complexity
$T(n) = O(n)$
$M(n) = O(1)$
where $T$ is time, $M$ is additional memory, and $n$ is digits.count()
.
§Panics
Panics if log_base
is greater than the width of the digit type, or if
log_base
is zero.
§Examples
See here.