diff options
Diffstat (limited to 'vendor/crypto-bigint/src/limb/bits.rs')
-rw-r--r-- | vendor/crypto-bigint/src/limb/bits.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/vendor/crypto-bigint/src/limb/bits.rs b/vendor/crypto-bigint/src/limb/bits.rs index c470ae9ab..02a74de5d 100644 --- a/vendor/crypto-bigint/src/limb/bits.rs +++ b/vendor/crypto-bigint/src/limb/bits.rs @@ -3,6 +3,16 @@ use super::Limb; impl Limb { /// Calculate the number of bits needed to represent this number. pub const fn bits(self) -> usize { - Limb::BIT_SIZE - (self.0.leading_zeros() as usize) + Limb::BITS - (self.0.leading_zeros() as usize) + } + + /// Calculate the number of leading zeros in the binary representation of this number. + pub const fn leading_zeros(self) -> usize { + self.0.leading_zeros() as usize + } + + /// Calculate the number of trailing zeros in the binary representation of this number. + pub const fn trailing_zeros(self) -> usize { + self.0.trailing_zeros() as usize } } |