Trait 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§

Source

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.

Source

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.

Source

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.

Source

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Digits<u8> for u8

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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

Source§

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>

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>

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>

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.

Implementors§