用法
pub const fn leading_zeros(self) -> u32
返回 self
的二进制表示中前导零的数量。
在许多架构上,此函数在底层整数类型上的性能优于leading_zeros()
,因为可以避免对零的特殊处理。
例子
基本用法:
let n = std::num::NonZeroIsize::new(-1isize).unwrap();
assert_eq!(n.leading_zeros(), 0);
相关用法
- Rust core::num::NonZeroIsize.saturating_pow用法及代码示例
- Rust core::num::NonZeroIsize.unsigned_abs用法及代码示例
- Rust core::num::NonZeroIsize.saturating_mul用法及代码示例
- Rust core::num::NonZeroIsize.checked_mul用法及代码示例
- Rust core::num::NonZeroIsize.checked_abs用法及代码示例
- Rust core::num::NonZeroIsize.overflowing_abs用法及代码示例
- Rust core::num::NonZeroIsize.abs用法及代码示例
- Rust core::num::NonZeroIsize.wrapping_abs用法及代码示例
- Rust core::num::NonZeroIsize.unchecked_mul用法及代码示例
- Rust core::num::NonZeroIsize.trailing_zeros用法及代码示例
- Rust core::num::NonZeroIsize.checked_pow用法及代码示例
- Rust core::num::NonZeroIsize.saturating_abs用法及代码示例
- Rust core::num::NonZeroIsize用法及代码示例
- Rust core::num::NonZeroI64.unchecked_mul用法及代码示例
- Rust core::num::NonZeroI32.checked_pow用法及代码示例
- Rust core::num::NonZeroI8.saturating_mul用法及代码示例
- Rust core::num::NonZeroI8.saturating_pow用法及代码示例
- Rust core::num::NonZeroI32.wrapping_abs用法及代码示例
- Rust core::num::NonZeroI16.checked_mul用法及代码示例
- Rust core::num::NonZeroI8.checked_abs用法及代码示例
注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 core::num::NonZeroIsize.leading_zeros。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。