Skip to main content

ConstIlog

Trait ConstIlog 

Source
pub trait ConstIlog:
    Sized
    + ConstZero
    + ConstOne
    + Ord
    + Div<Output = Self> {
    // Required methods
    fn ilog2(self) -> u32;
    fn ilog10(self) -> u32;
    fn ilog(self, base: Self) -> u32;
    fn checked_ilog2(self) -> Option<u32>;
    fn checked_ilog10(self) -> Option<u32>;
    fn checked_ilog(self, base: Self) -> Option<u32>;
}
Expand description

Const-compatible integer logarithm operations.

§Unsigned types only

This trait is designed for unsigned integer types. The logarithm of zero is undefined and will panic (or return None for checked variants).

Required Methods§

Source

fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

§Panics

Panics if self is zero.

Source

fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

§Panics

Panics if self is zero.

Source

fn ilog(self, base: Self) -> u32

Returns the logarithm of the number with respect to an arbitrary base, rounded down.

§Panics

Panics if self is zero, or if base is less than 2.

Source

fn checked_ilog2(self) -> Option<u32>

Returns the base 2 logarithm of the number, rounded down.

Returns None if self is zero.

Source

fn checked_ilog10(self) -> Option<u32>

Returns the base 10 logarithm of the number, rounded down.

Returns None if self is zero.

Source

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

Returns the logarithm of the number with respect to an arbitrary base, rounded down.

Returns None if self is zero, or if base is less than 2.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ConstIlog for u8

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn ilog(self, base: Self) -> u32

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

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

Source§

impl ConstIlog for u16

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn ilog(self, base: Self) -> u32

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

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

Source§

impl ConstIlog for u32

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn ilog(self, base: Self) -> u32

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

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

Source§

impl ConstIlog for u64

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn ilog(self, base: Self) -> u32

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

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

Source§

impl ConstIlog for u128

Source§

fn ilog2(self) -> u32

Source§

fn ilog10(self) -> u32

Source§

fn ilog(self, base: Self) -> u32

Source§

fn checked_ilog2(self) -> Option<u32>

Source§

fn checked_ilog10(self) -> Option<u32>

Source§

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

Implementors§

Source§

impl<T: ConstMachineWord + MachineWord, const N: usize> ConstIlog for FixedUInt<T, N, Nct>