Trait CeilingLogBase2

Source
pub trait CeilingLogBase2 {
    type Output;

    // Required method
    fn ceiling_log_base_2(self) -> Self::Output;
}
Expand description

Calculates the ceiling of the base-2 logarithm of a number.

Required Associated Types§

Required Methods§

Implementations on Foreign Types§

Source§

impl CeilingLogBase2 for f32

Source§

fn ceiling_log_base_2(self) -> i64

Returns the ceiling of the base-2 logarithm of a positive float.

$f(x) = \lceil\log_2 x\rceil$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is infinite, NaN, or less than or equal to zero.

§Examples

See here.

Source§

type Output = i64

Source§

impl CeilingLogBase2 for f64

Source§

fn ceiling_log_base_2(self) -> i64

Returns the ceiling of the base-2 logarithm of a positive float.

$f(x) = \lceil\log_2 x\rceil$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is infinite, NaN, or less than or equal to zero.

§Examples

See here.

Source§

type Output = i64

Source§

impl CeilingLogBase2 for u8

Source§

fn ceiling_log_base_2(self) -> u64

Returns the ceiling of the base-2 logarithm of a positive integer.

$f(x) = \lceil\log_2 x\rceil$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is 0.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase2 for u16

Source§

fn ceiling_log_base_2(self) -> u64

Returns the ceiling of the base-2 logarithm of a positive integer.

$f(x) = \lceil\log_2 x\rceil$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is 0.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase2 for u32

Source§

fn ceiling_log_base_2(self) -> u64

Returns the ceiling of the base-2 logarithm of a positive integer.

$f(x) = \lceil\log_2 x\rceil$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is 0.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase2 for u64

Source§

fn ceiling_log_base_2(self) -> u64

Returns the ceiling of the base-2 logarithm of a positive integer.

$f(x) = \lceil\log_2 x\rceil$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is 0.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase2 for u128

Source§

fn ceiling_log_base_2(self) -> u64

Returns the ceiling of the base-2 logarithm of a positive integer.

$f(x) = \lceil\log_2 x\rceil$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is 0.

§Examples

See here.

Source§

type Output = u64

Source§

impl CeilingLogBase2 for usize

Source§

fn ceiling_log_base_2(self) -> u64

Returns the ceiling of the base-2 logarithm of a positive integer.

$f(x) = \lceil\log_2 x\rceil$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if self is 0.

§Examples

See here.

Source§

type Output = u64

Implementors§