[][src]Function safe_arch::bit_lowest_set_mask_u32

#[must_use]pub fn bit_lowest_set_mask_u32(a: u32) -> u32
This is supported with target feature bmi1 only.

Gets the mask of all bits up to and including the lowest set bit in a u32.

If the input is 0, you get u32::MAX

  • Formula: (a - 1) ^ a
assert_eq!(bit_lowest_set_mask_u32(0b0), u32::MAX);
assert_eq!(bit_lowest_set_mask_u32(0b1), 0b1);
assert_eq!(bit_lowest_set_mask_u32(0b10), 0b11);
assert_eq!(bit_lowest_set_mask_u32(0b100), 0b111);
assert_eq!(bit_lowest_set_mask_u32(0b111100), 0b111);