pub trait BinInteger: Clone + Copy + PartialEq + Eq + Ord + PartialOrd + Unpin + Add<Output = Self> + Sub<Output = Self> + Mul<Output = Self> + Div<Output = Self> + Rem<Output = Self> + Sized + AddAssign + SubAssign + MulAssign + DivAssign + RemAssign + Debug + Send + Sync + 'static + Sealed {
    const ZERO: Self;
    const BITS: u32;

    fn ones(range: Range<u32>) -> Self;
    fn ones_truncated(range: Range<u32>) -> Self;
    fn trailing_zeros(&self) -> u32;
    fn leading_zeros(&self) -> u32;
    fn count_ones(&self) -> u32;
    fn bit_scan_forward(&self, start: u32) -> u32;
    fn extract_u32(&self, range: Range<u32>) -> u32;
    fn get_bit(&self, i: u32) -> bool;
    fn set_bit(&mut self, i: u32);
    fn clear_bit(&mut self, i: u32);
    fn checked_ceil_fix(self, fp: u32) -> Option<Self>;
}
Expand description

Integral types with efficient binary operations.

Required Associated Constants

Required Methods

Return the number of trailing zeros in its binary representation.

Return the number of leading zeros in its binary representation.

Return the number of ones in its binary representation.

Return the position of the least significant set bit since the position start.

Retruns Self::BITS if none was found.

Slice a part of its binary representation as u32.

Retrieve whether the specified bit is set or not.

Set a single bit.

Clear a single bit.

Perform ceil treating the value as a fixed point number with fp fractional part digits.

Implementations on Foreign Types

Implementors