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