用法
pub const fn wrapping_shr(self, rhs:u32) -> u64
Panic-free 按位 shift-right;产生 self >> mask(rhs)
,其中 mask
删除 rhs
的任何 high-order 位,这将导致移位超过类型的位宽。
请注意,这与 rotate-right 不同;包装 shift-right 的 RHS 被限制在类型的范围内,而不是从 LHS 移出的位被返回到另一端。原始整数类型都实现了 rotate_right 函数,这可能是您想要的。
例子
基本用法:
assert_eq!(128u64.wrapping_shr(7), 1);
assert_eq!(128u64.wrapping_shr(128), 128);
相关用法
- Rust u64.wrapping_shl用法及代码示例
- Rust u64.wrapping_sub用法及代码示例
- Rust u64.wrapping_div用法及代码示例
- Rust u64.wrapping_rem_euclid用法及代码示例
- Rust u64.wrapping_mul用法及代码示例
- Rust u64.wrapping_next_power_of_two用法及代码示例
- Rust u64.wrapping_div_euclid用法及代码示例
- Rust u64.wrapping_add用法及代码示例
- Rust u64.wrapping_pow用法及代码示例
- Rust u64.wrapping_add_signed用法及代码示例
- Rust u64.wrapping_rem用法及代码示例
- Rust u64.wrapping_neg用法及代码示例
- Rust u64.widening_mul用法及代码示例
- Rust u64.div_euclid用法及代码示例
- Rust u64.is_power_of_two用法及代码示例
- Rust u64.overflowing_mul用法及代码示例
- Rust u64.log用法及代码示例
- Rust u64.carrying_mul用法及代码示例
- Rust u64.overflowing_neg用法及代码示例
- Rust u64.from_le_bytes用法及代码示例
注:本文由堆栈答案筛选整理自rust-lang.org大神的英文原创作品 u64.wrapping_shr。非经特殊声明,原始代码版权归原作者所有,本译文的传播和使用请遵循“署名-相同方式共享 4.0 国际 (CC BY-SA 4.0)”协议。