Trait malachite_base::num::conversion::traits::Digits
source · pub trait Digits<T>: Sized {
// Required methods
fn to_digits_asc(&self, base: &T) -> Vec<T>;
fn to_digits_desc(&self, base: &T) -> Vec<T>;
fn from_digits_asc<I: Iterator<Item = T>>(
base: &T,
digits: I,
) -> Option<Self>;
fn from_digits_desc<I: Iterator<Item = T>>(
base: &T,
digits: I,
) -> Option<Self>;
}
Expand description
Expresses a value as a Vec
of digits, or reads a value from an iterator of digits.
The trait is parameterized by T
, which is both the digit type and the base type.
Required Methods§
sourcefn to_digits_asc(&self, base: &T) -> Vec<T>
fn to_digits_asc(&self, base: &T) -> Vec<T>
Returns a Vec
containing the digits of a value in ascending order: least- to
most-significant.
sourcefn to_digits_desc(&self, base: &T) -> Vec<T>
fn to_digits_desc(&self, base: &T) -> Vec<T>
Returns a Vec
containing the digits of a value in descending order: most- to
least-significant.
sourcefn from_digits_asc<I: Iterator<Item = T>>(base: &T, digits: I) -> Option<Self>
fn from_digits_asc<I: Iterator<Item = T>>(base: &T, digits: I) -> Option<Self>
Converts an iterator of digits into a value.
The input digits are in ascending order: least- to most-significant.
sourcefn from_digits_desc<I: Iterator<Item = T>>(base: &T, digits: I) -> Option<Self>
fn from_digits_desc<I: Iterator<Item = T>>(base: &T, digits: I) -> Option<Self>
Converts an iterator of digits into a value.
The input digits are in descending order: most- to least-significant.
Object Safety§
Implementations on Foreign Types§
source§impl Digits<u8> for u8
impl Digits<u8> for u8
source§fn to_digits_asc(&self, base: &u8) -> Vec<u8>
fn to_digits_asc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u8) -> Vec<u8>
fn to_digits_desc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u8>
fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u8>
fn from_digits_desc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u8> for u16
impl Digits<u8> for u16
source§fn to_digits_asc(&self, base: &u8) -> Vec<u8>
fn to_digits_asc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u8) -> Vec<u8>
fn to_digits_desc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u16>
fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u16>
fn from_digits_desc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u8> for u32
impl Digits<u8> for u32
source§fn to_digits_asc(&self, base: &u8) -> Vec<u8>
fn to_digits_asc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u8) -> Vec<u8>
fn to_digits_desc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u32>
fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u32>
fn from_digits_desc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u8> for u64
impl Digits<u8> for u64
source§fn to_digits_asc(&self, base: &u8) -> Vec<u8>
fn to_digits_asc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u8) -> Vec<u8>
fn to_digits_desc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u64>
fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u64>
fn from_digits_desc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u8> for u128
impl Digits<u8> for u128
source§fn to_digits_asc(&self, base: &u8) -> Vec<u8>
fn to_digits_asc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u8) -> Vec<u8>
fn to_digits_desc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u128>
fn from_digits_asc<I: Iterator<Item = u8>>(base: &u8, digits: I) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u8>>(
base: &u8,
digits: I,
) -> Option<u128>
fn from_digits_desc<I: Iterator<Item = u8>>( base: &u8, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u8> for usize
impl Digits<u8> for usize
source§fn to_digits_asc(&self, base: &u8) -> Vec<u8>
fn to_digits_asc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u8) -> Vec<u8>
fn to_digits_desc(&self, base: &u8) -> Vec<u8>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u8>>(
base: &u8,
digits: I,
) -> Option<usize>
fn from_digits_asc<I: Iterator<Item = u8>>( base: &u8, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u8>>(
base: &u8,
digits: I,
) -> Option<usize>
fn from_digits_desc<I: Iterator<Item = u8>>( base: &u8, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u16> for u8
impl Digits<u16> for u8
source§fn to_digits_asc(&self, base: &u16) -> Vec<u16>
fn to_digits_asc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u16) -> Vec<u16>
fn to_digits_desc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u16>>(base: &u16, digits: I) -> Option<u8>
fn from_digits_asc<I: Iterator<Item = u16>>(base: &u16, digits: I) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<u8>
fn from_digits_desc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u16> for u16
impl Digits<u16> for u16
source§fn to_digits_asc(&self, base: &u16) -> Vec<u16>
fn to_digits_asc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u16) -> Vec<u16>
fn to_digits_desc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<u16>
fn from_digits_asc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<u16>
fn from_digits_desc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u16> for u32
impl Digits<u16> for u32
source§fn to_digits_asc(&self, base: &u16) -> Vec<u16>
fn to_digits_asc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u16) -> Vec<u16>
fn to_digits_desc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<u32>
fn from_digits_asc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<u32>
fn from_digits_desc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u16> for u64
impl Digits<u16> for u64
source§fn to_digits_asc(&self, base: &u16) -> Vec<u16>
fn to_digits_asc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u16) -> Vec<u16>
fn to_digits_desc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<u64>
fn from_digits_asc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<u64>
fn from_digits_desc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u16> for u128
impl Digits<u16> for u128
source§fn to_digits_asc(&self, base: &u16) -> Vec<u16>
fn to_digits_asc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u16) -> Vec<u16>
fn to_digits_desc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<u128>
fn from_digits_asc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<u128>
fn from_digits_desc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u16> for usize
impl Digits<u16> for usize
source§fn to_digits_asc(&self, base: &u16) -> Vec<u16>
fn to_digits_asc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u16) -> Vec<u16>
fn to_digits_desc(&self, base: &u16) -> Vec<u16>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<usize>
fn from_digits_asc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u16>>(
base: &u16,
digits: I,
) -> Option<usize>
fn from_digits_desc<I: Iterator<Item = u16>>( base: &u16, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u32> for u8
impl Digits<u32> for u8
source§fn to_digits_asc(&self, base: &u32) -> Vec<u32>
fn to_digits_asc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u32) -> Vec<u32>
fn to_digits_desc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u32>>(base: &u32, digits: I) -> Option<u8>
fn from_digits_asc<I: Iterator<Item = u32>>(base: &u32, digits: I) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<u8>
fn from_digits_desc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u32> for u16
impl Digits<u32> for u16
source§fn to_digits_asc(&self, base: &u32) -> Vec<u32>
fn to_digits_asc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u32) -> Vec<u32>
fn to_digits_desc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<u16>
fn from_digits_asc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<u16>
fn from_digits_desc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u32> for u32
impl Digits<u32> for u32
source§fn to_digits_asc(&self, base: &u32) -> Vec<u32>
fn to_digits_asc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u32) -> Vec<u32>
fn to_digits_desc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<u32>
fn from_digits_asc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<u32>
fn from_digits_desc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u32> for u64
impl Digits<u32> for u64
source§fn to_digits_asc(&self, base: &u32) -> Vec<u32>
fn to_digits_asc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u32) -> Vec<u32>
fn to_digits_desc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<u64>
fn from_digits_asc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<u64>
fn from_digits_desc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u32> for u128
impl Digits<u32> for u128
source§fn to_digits_asc(&self, base: &u32) -> Vec<u32>
fn to_digits_asc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u32) -> Vec<u32>
fn to_digits_desc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<u128>
fn from_digits_asc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<u128>
fn from_digits_desc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u32> for usize
impl Digits<u32> for usize
source§fn to_digits_asc(&self, base: &u32) -> Vec<u32>
fn to_digits_asc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u32) -> Vec<u32>
fn to_digits_desc(&self, base: &u32) -> Vec<u32>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<usize>
fn from_digits_asc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u32>>(
base: &u32,
digits: I,
) -> Option<usize>
fn from_digits_desc<I: Iterator<Item = u32>>( base: &u32, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u64> for u8
impl Digits<u64> for u8
source§fn to_digits_asc(&self, base: &u64) -> Vec<u64>
fn to_digits_asc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u64) -> Vec<u64>
fn to_digits_desc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u64>>(base: &u64, digits: I) -> Option<u8>
fn from_digits_asc<I: Iterator<Item = u64>>(base: &u64, digits: I) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<u8>
fn from_digits_desc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u64> for u16
impl Digits<u64> for u16
source§fn to_digits_asc(&self, base: &u64) -> Vec<u64>
fn to_digits_asc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u64) -> Vec<u64>
fn to_digits_desc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<u16>
fn from_digits_asc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<u16>
fn from_digits_desc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u64> for u32
impl Digits<u64> for u32
source§fn to_digits_asc(&self, base: &u64) -> Vec<u64>
fn to_digits_asc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u64) -> Vec<u64>
fn to_digits_desc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<u32>
fn from_digits_asc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<u32>
fn from_digits_desc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u64> for u64
impl Digits<u64> for u64
source§fn to_digits_asc(&self, base: &u64) -> Vec<u64>
fn to_digits_asc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u64) -> Vec<u64>
fn to_digits_desc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<u64>
fn from_digits_asc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<u64>
fn from_digits_desc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u64> for u128
impl Digits<u64> for u128
source§fn to_digits_asc(&self, base: &u64) -> Vec<u64>
fn to_digits_asc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u64) -> Vec<u64>
fn to_digits_desc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<u128>
fn from_digits_asc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<u128>
fn from_digits_desc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u64> for usize
impl Digits<u64> for usize
source§fn to_digits_asc(&self, base: &u64) -> Vec<u64>
fn to_digits_asc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u64) -> Vec<u64>
fn to_digits_desc(&self, base: &u64) -> Vec<u64>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<usize>
fn from_digits_asc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u64>>(
base: &u64,
digits: I,
) -> Option<usize>
fn from_digits_desc<I: Iterator<Item = u64>>( base: &u64, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u128> for u8
impl Digits<u128> for u8
source§fn to_digits_asc(&self, base: &u128) -> Vec<u128>
fn to_digits_asc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u128) -> Vec<u128>
fn to_digits_desc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u8>
fn from_digits_asc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u8>
fn from_digits_desc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u128> for u16
impl Digits<u128> for u16
source§fn to_digits_asc(&self, base: &u128) -> Vec<u128>
fn to_digits_asc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u128) -> Vec<u128>
fn to_digits_desc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u16>
fn from_digits_asc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u16>
fn from_digits_desc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u128> for u32
impl Digits<u128> for u32
source§fn to_digits_asc(&self, base: &u128) -> Vec<u128>
fn to_digits_asc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u128) -> Vec<u128>
fn to_digits_desc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u32>
fn from_digits_asc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u32>
fn from_digits_desc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u128> for u64
impl Digits<u128> for u64
source§fn to_digits_asc(&self, base: &u128) -> Vec<u128>
fn to_digits_asc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u128) -> Vec<u128>
fn to_digits_desc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u64>
fn from_digits_asc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u64>
fn from_digits_desc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u128> for u128
impl Digits<u128> for u128
source§fn to_digits_asc(&self, base: &u128) -> Vec<u128>
fn to_digits_asc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u128) -> Vec<u128>
fn to_digits_desc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u128>
fn from_digits_asc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<u128>
fn from_digits_desc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<u128> for usize
impl Digits<u128> for usize
source§fn to_digits_asc(&self, base: &u128) -> Vec<u128>
fn to_digits_asc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &u128) -> Vec<u128>
fn to_digits_desc(&self, base: &u128) -> Vec<u128>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<usize>
fn from_digits_asc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = u128>>(
base: &u128,
digits: I,
) -> Option<usize>
fn from_digits_desc<I: Iterator<Item = u128>>( base: &u128, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<usize> for u8
impl Digits<usize> for u8
source§fn to_digits_asc(&self, base: &usize) -> Vec<usize>
fn to_digits_asc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &usize) -> Vec<usize>
fn to_digits_desc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u8>
fn from_digits_asc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u8>
fn from_digits_desc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u8>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<usize> for u16
impl Digits<usize> for u16
source§fn to_digits_asc(&self, base: &usize) -> Vec<usize>
fn to_digits_asc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &usize) -> Vec<usize>
fn to_digits_desc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u16>
fn from_digits_asc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u16>
fn from_digits_desc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u16>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<usize> for u32
impl Digits<usize> for u32
source§fn to_digits_asc(&self, base: &usize) -> Vec<usize>
fn to_digits_asc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &usize) -> Vec<usize>
fn to_digits_desc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u32>
fn from_digits_asc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u32>
fn from_digits_desc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u32>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<usize> for u64
impl Digits<usize> for u64
source§fn to_digits_asc(&self, base: &usize) -> Vec<usize>
fn to_digits_asc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &usize) -> Vec<usize>
fn to_digits_desc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u64>
fn from_digits_asc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u64>
fn from_digits_desc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u64>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<usize> for u128
impl Digits<usize> for u128
source§fn to_digits_asc(&self, base: &usize) -> Vec<usize>
fn to_digits_asc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &usize) -> Vec<usize>
fn to_digits_desc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u128>
fn from_digits_asc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<u128>
fn from_digits_desc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<u128>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.
source§impl Digits<usize> for usize
impl Digits<usize> for usize
source§fn to_digits_asc(&self, base: &usize) -> Vec<usize>
fn to_digits_asc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in ascending order
(least- to most-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it ends with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i 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 base
is less than 2 or greater than Self::MAX
.
§Examples
See here.
source§fn to_digits_desc(&self, base: &usize) -> Vec<usize>
fn to_digits_desc(&self, base: &usize) -> Vec<usize>
Returns a Vec
containing the digits of a number in descending order
(most- to least-significant).
The base must be convertible to Self
. If self
is 0, the Vec
is
empty; otherwise, it begins with a nonzero digit.
$f(x, b) = (d_i)_ {i=0}^{k-1}$, where $0 \leq d_i < b$ for all $i$, $k=0$ or $d_{k-1} \neq 0$, and
$$ \sum_{i=0}^{k-1}b^i d_{k-i-1} = 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 base
is less than 2 or greater than $t::MAX
.
§Examples
See here.
source§fn from_digits_asc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<usize>
fn from_digits_asc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in ascending order (least- to most-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^id_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 base
is less than 2.
§Examples
See here.
source§fn from_digits_desc<I: Iterator<Item = usize>>(
base: &usize,
digits: I,
) -> Option<usize>
fn from_digits_desc<I: Iterator<Item = usize>>( base: &usize, digits: I, ) -> Option<usize>
Converts an iterator of digits into a value.
The input digits are in descending order (most- to least-significant). The
base must be no larger than Self::MAX
. The function returns None
if the
input represents a number that can’t fit in Self
, if base
is greater
than Self::MAX
, or if any of the digits are greater than or equal to the
base.
$$ f((d_i)_ {i=0}^{k-1}, b) = \sum_{i=0}^{k-1}b^{k-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 base
is less than 2.
§Examples
See here.