Skip to main content

CeilingLogBase

Trait CeilingLogBase 

Source
pub trait CeilingLogBase<B = Self> {
    type Output;

    // Required method
    fn ceiling_log_base(self, base: B) -> Self::Output;
}
Expand description

Calculates the ceiling of the base-$b$ logarithm of a number.

Required Associated Types§

Required Methods§

Source

fn ceiling_log_base(self, base: B) -> Self::Output

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl CeilingLogBase for u8

Source§

fn ceiling_log_base(self, base: u8) -> u64

Returns the ceiling of the base-$b$ logarithm of a positive integer.

$f(x, b) = \lceil\log_b x\rceil$.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(1)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits() / base.significant_bits().

§Panics

Panics if self is 0 or base is less than 2.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase for u16

Source§

fn ceiling_log_base(self, base: u16) -> u64

Returns the ceiling of the base-$b$ logarithm of a positive integer.

$f(x, b) = \lceil\log_b x\rceil$.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(1)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits() / base.significant_bits().

§Panics

Panics if self is 0 or base is less than 2.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase for u32

Source§

fn ceiling_log_base(self, base: u32) -> u64

Returns the ceiling of the base-$b$ logarithm of a positive integer.

$f(x, b) = \lceil\log_b x\rceil$.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(1)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits() / base.significant_bits().

§Panics

Panics if self is 0 or base is less than 2.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase for u64

Source§

fn ceiling_log_base(self, base: u64) -> u64

Returns the ceiling of the base-$b$ logarithm of a positive integer.

$f(x, b) = \lceil\log_b x\rceil$.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(1)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits() / base.significant_bits().

§Panics

Panics if self is 0 or base is less than 2.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase for u128

Source§

fn ceiling_log_base(self, base: u128) -> u64

Returns the ceiling of the base-$b$ logarithm of a positive integer.

$f(x, b) = \lceil\log_b x\rceil$.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(1)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits() / base.significant_bits().

§Panics

Panics if self is 0 or base is less than 2.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase for usize

Source§

fn ceiling_log_base(self, base: usize) -> u64

Returns the ceiling of the base-$b$ logarithm of a positive integer.

$f(x, b) = \lceil\log_b x\rceil$.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(1)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits() / base.significant_bits().

§Panics

Panics if self is 0 or base is less than 2.

§Examples

See here.

Source§

type Output = u64

Implementors§