[−][src]Function safe_arch::bit_lowest_set_mask_u64
#[must_use]pub fn bit_lowest_set_mask_u64(a: u64) -> u64
This is supported with target feature
bmi1
only.Gets the mask of all bits up to and including the lowest set bit in a u64
.
If the input is 0, you get u64::MAX
- Formula:
(a - 1) ^ a
assert_eq!(bit_lowest_set_mask_u64(0b0), u64::MAX); assert_eq!(bit_lowest_set_mask_u64(0b1), 0b1); assert_eq!(bit_lowest_set_mask_u64(0b10), 0b11); assert_eq!(bit_lowest_set_mask_u64(0b100), 0b111); assert_eq!(bit_lowest_set_mask_u64(0b111100), 0b111);