/rust/registry/src/index.crates.io-1949cf8c6b5b557f/crypto-bigint-0.5.5/src/limb/bits.rs
Line | Count | Source |
1 | | use super::Limb; |
2 | | |
3 | | impl Limb { |
4 | | /// Calculate the number of bits needed to represent this number. |
5 | 0 | pub const fn bits(self) -> usize { |
6 | 0 | Limb::BITS - (self.0.leading_zeros() as usize) |
7 | 0 | } |
8 | | |
9 | | /// Calculate the number of leading zeros in the binary representation of this number. |
10 | 0 | pub const fn leading_zeros(self) -> usize { |
11 | 0 | self.0.leading_zeros() as usize |
12 | 0 | } |
13 | | |
14 | | /// Calculate the number of trailing zeros in the binary representation of this number. |
15 | 0 | pub const fn trailing_zeros(self) -> usize { |
16 | 0 | self.0.trailing_zeros() as usize |
17 | 0 | } |
18 | | |
19 | | /// Calculate the number of trailing ones the binary representation of this number. |
20 | 0 | pub const fn trailing_ones(self) -> usize { |
21 | 0 | self.0.trailing_ones() as usize |
22 | 0 | } |
23 | | } |