Trait mycelium_util::math::Logarithm

source ·
pub trait Logarithm: Sized {
    // Required methods
    fn log2_ceil(self) -> Self;
    fn log2(self) -> Self;
    fn checked_log(self, base: Self) -> Option<Self>;
    fn log(self, base: Self) -> Self;
}
Expand description

Extension trait adding logarithm methods to integers.

Required Methods§

source

fn log2_ceil(self) -> Self

Returns ceiling(log2(self)).

source

fn log2(self) -> Self

Returns log2(self).

source

fn checked_log(self, base: Self) -> Option<Self>

Returns the integer logarithm base base of self, or None if it is not possible to take the log base base of self.

source

fn log(self, base: Self) -> Self

Returns the integer logarithm base base of self.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Logarithm for usize

source§

fn log2_ceil(self) -> usize

source§

fn log2(self) -> usize

source§

fn checked_log(self, base: usize) -> Option<Self>

source§

fn log(self, base: usize) -> Self

Implementors§