crypto_bigint/limb/
bits.rs

1use super::Limb;
2
3impl Limb {
4    /// Calculate the number of bits needed to represent this number.
5    pub const fn bits(self) -> usize {
6        Limb::BITS - (self.0.leading_zeros() as usize)
7    }
8
9    /// Calculate the number of leading zeros in the binary representation of this number.
10    pub const fn leading_zeros(self) -> usize {
11        self.0.leading_zeros() as usize
12    }
13
14    /// Calculate the number of trailing zeros in the binary representation of this number.
15    pub const fn trailing_zeros(self) -> usize {
16        self.0.trailing_zeros() as usize
17    }
18
19    /// Calculate the number of trailing ones the binary representation of this number.
20    pub const fn trailing_ones(self) -> usize {
21        self.0.trailing_ones() as usize
22    }
23}